Skip to content

Instantly share code, notes, and snippets.

@goosmurf
Created January 14, 2010 05:46
Show Gist options
  • Save goosmurf/276931 to your computer and use it in GitHub Desktop.
Save goosmurf/276931 to your computer and use it in GitHub Desktop.
> db.t.remove()
> db.t.insert( { players: [ {player_name: "m", player_position: 3}, {player_name: "blah", player_position: 3} ] } )
> db.t.insert( { players: [ {player_name: "another", player_position: 3}, {player_name: "m", player_position: 5} ] } )
> db.t.find( { "players": { player_name: "m", "player_position": 3 }} )
{ "_id" : ObjectId("4b4eaf902976dc62f4b0f9de"), "players" : [
{
"player_name" : "m",
"player_position" : 3
},
{
"player_name" : "blah",
"player_position" : 3
}
] }
> db.t.find( { "players.player_name": "m", "players.player_position": 3 } ) { "_id" : ObjectId("4b4eaf902976dc62f4b0f9de"), "players" : [
{
"player_name" : "m",
"player_position" : 3
},
{
"player_name" : "blah",
"player_position" : 3
}
] }
{ "_id" : ObjectId("4b4eaf962976dc62f4b0f9df"), "players" : [
{
"player_name" : "another",
"player_position" : 3
},
{
"player_name" : "m",
"player_position" : 5
}
] }
>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment