spot7.org logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories

How to search for a value inside na array with pymongo


looks like you need to search the documents collection on a level deeper.

As of now you search for the element

{
    "$oid": "54723c55b59c44a167ed3424"
}

And the $in operator of your documents collection compares it to the list elements such as:

[
    {
        "$oid": "54723c55b59c44a167ed3424"
    },
    7
]

which obviously aren't the same ever. Unfortunately I don't have a mongodb to test any but maybe that tip helps you a little to improve your query.

EDIT: Found an older question here regarding a similar problem maybe that'll helps. According to that post something like the following works:

for page in
documents.find({'words':{$elemMatch:{$elemMatch:{$in:[word['_id']]}}}})

Categories : Python

Related to : How to search for a value inside na array with pymongo
MongoDB - Update or Create an object in nested Array in Pymongo
You almost there: db.YourCollection.update( { '_id':'50001', <-- to find document 'data.name': 'jango' < -- to find element of the array }, { '$set': { "data.$.grade" : 'A' } } <-- with .$ you reference array element from first argument ) Link to documentation

Categories : Mongodb
how can I insert a new book in a book list inside a classroom collection using pymongo for mongodb?
its your answer db.collection.update( {'students.name' : 'john'}, {$push : {'students.$.books': { "title" : "new book", "pages" : 3000, "author" : "Me" } } });

Categories : Mongodb
How to read array inside JSON Object this is inside another array
Loop through json Array like, for(var i=0; i< RelatedTopics.length;i++){ if($.isArray(RelatedTopics[i])){ for(var j=0; j< RelatedTopics[i].Topics.length;j++){ var topics=RelatedTopics[i].Topics[j]; var text = topics.Text; var firsturl = topics.Firsturl; var url = topics.Icon.url; } } } if you want push it an array variable

Categories : Javascript
How to search for a string pattern inside html, coding in C?
HTML parsing "the right way" is way more complicated than checking for one string at a time. My code below does more things not right than the other way around -- but part of this is due to a lack of information. Is your HTML well-formed? Can the title attribute contain the strings li or title, or stray < or > characters? Do you need to take into account that spaces may occur inside tags, s

Categories : C
Search box inside Flash, read data from local xml (actionscript)
I wrote a code that work very well with your xml file. I used a btn_search button and txt_search text field that I inserted in my main stage. Firstly we load our xml file, then we type a player name in our txt_search and then run the search with btn_search: var xml:XML = new XML() xml.load('xmldata.xml') btn_search.onRelease = function(){ if(txt_search.text != ''){ search_play

Categories : Xml
Recently Add
Adding json to new Django database
document clustering in python
Only read the last character in a .txt file
Is it possible to redirect to different domain retaining the trailing endpoint, from a route?
Python NameError: not defined
Numpy array loop
Turning off Tick Marks in Bokeh
Python: Number and operator concatenation not working (Euler's Method)
Python: Twitter API tweets/search: Flatten nested dictionary to columns
Python 2.7 cmd autocomplete readline buffers seem stale
Memory usage/efficiency for pandas dataframe versus lists versus tuples, etc.
How can i use multiple lists as arguments in a function and receive them differently?
PyQt - setText method of QTableWidget gets AttributeError
Matplotlib - get value of autoscale
Backwards axes in numpy.delete
Twilio - How to determine the length of a conference call?
Counting string using for loop
Automating creation of class instances in python for an undetermined amount of instances
Printing 2D-array in a grid
Load PreComputed Vectors Gensim
IPython _repr_html_
Reversing a number using recursion
Is there a configuration under which a numpy operation will work on more than a single core/thread?
Is there a better way to write this if-statement?
Python: Effective reading from a file using csv module
Django/Python: CSV for-in loop overriding first row each time through
How to read the pickled igraph graph object from old version by new version igraph
Tornado WebSocket with Django ORM with shared session
trying to plot contours of bivariate normal, won't work with a correlation term
Python split users input
© Copyright 2017 spot7.org Publishing Limited. All rights reserved.