Skip to content

Instantly share code, notes, and snippets.

@scotthernandez
Created December 20, 2010 23:37
Show Gist options
  • Save scotthernandez/749228 to your computer and use it in GitHub Desktop.
Save scotthernandez/749228 to your computer and use it in GitHub Desktop.
> db.a.save({_id:1, vals: {first:[1,2,3,], second:[1,2,3]}})
> db.a.find()
{ "_id" : 1, "vals" : { "first" : [ 1, 2, 3 ], "second" : [ 1, 2, 3 ] } }
> db.a.find({},{"vals.first":{$slice:2}})
{ "_id" : 1, "vals" : { "first" : [ 1, 2 ], "second" : [ 1, 2, 3 ] } }
//I would have expected this to work... might call that a bug.
> db.a.find({},{"vals.first":1, "vals.first":{$slice:2}})
{ "_id" : 1, "vals" : { "first" : [ 1, 2 ], "second" : [ 1, 2, 3 ] } }
> db.a.find({},{"vals":0, "vals.first":{$slice:2}})
{ "_id" : 1, "vals" : { "first" : [ 1, 2 ] } }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment