Skip to content

Instantly share code, notes, and snippets.

@biilmann
Created December 4, 2010 23:32
Show Gist options
  • Select an option

  • Save biilmann/728602 to your computer and use it in GitHub Desktop.

Select an option

Save biilmann/728602 to your computer and use it in GitHub Desktop.
Anyway to get just one element in an embedded array?
db.users.insert({"name": "Pepe", "projects": [{"id": "123", "role": 1}, {"id": "234", "role": 1}, {"id": "345", "role": 2}, ...]});
var user = db.find({"projects.id": "234"});
// Any way to get just: user:
{
"name": "Pepe",
"projects": [{"id": "234", "role": 1}]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment