python - MongoDB search for each dict in list in collection -
I have For example, I want to find and last name, I am: Post-text "itemprop =" text "> Although it is mentioned that in reality there is no operator required, in both ways this is not the query that you want. Consider the following: It actually does match the given record because "Jones" There are two elements of "first name" equal to equal "aliis" and "last name" But surely the problem here is simple that there is no real element in the array, in which there is a sub-document for those two values. To match where the "both" criteria are given in an array element, you have to use the operator. This query condition is applied to the "element" of the array. And of course if you tried "Alice" and "Jones" then it does not match because in reality no element is involved in that operation. archive where
list has
dicts < / Code> and I want to find if a particular word has two specific
key: value .
find_one where my name is a word which includes a specific first and last name:
{"name "," "", "First name": "alias", "first name": "bob", "last name": "jones", "age": "34", "gender": "m"}, "Last name": "56", "gender": "F"}, {"first name": "Bob", "last name" is a record with "Bombay's Smith" or not To see that "Smith", "age": "19", "gender": "m"},]}
ago = 'Bob' final = 'Smith' nameExists = db.user.find_one ({'$ and': [{'names.first name': First, '
db.user.find_one ({'names.firstName': 'alice', 'names.lastName': 'jones'})
db.user.find_one ({'names': {'$ elemMatch': {'firstName': 'alice', 'last name': 'Smith'}})
Comments
Post a Comment