Friday 15 July 2011

mongodb - Can I'm get part of mongo document by find conditions? -


I have a foo archive with many documents, for example:

  {" _id ": ObjectId (" 51c46dc75d1e56f582940c9c ")," name ":" John "," age ": 25," address ": {" city ":" new "" phone ":" 212-555-1234 "," type ":" Home "}, {" phone ":" 646-555-1234 "," type ":" mobile "}]   

}

Can I get a document without a phone without a phone? For example - Mongo return documents with the fonts. Type = "mobile" I have ten without John without the phone having the "Home" type "John", "Age": 25, "Address": {"City": "Name": Object Name ("51c46dc75d1e56f582940c9c"), "Name": "John", "Age": 25, "Address": {"City" : "Phone": "646-555-1234", "Type": "Mobile"}] : "New York", "Postal code": "10021"}, "Phone": [

}

You can do this while executing find second By giving arguments, which is called projection - this is where you specify which part of the document you want As Uel, where you want to calculate commonly SELECT * does not say, but those columns that you actually returned.

Since this is an array, which you want to achieve only one matching element, you will need it.

Since this is your homework, so I will leave it to create the real search that you know how it should be done.

No comments:

Post a Comment