Skip to content

Instantly share code, notes, and snippets.

@masatomo
Created March 15, 2010 15:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save masatomo/332977 to your computer and use it in GitHub Desktop.
Save masatomo/332977 to your computer and use it in GitHub Desktop.
doc1: {"num": [3, 10, 25], "type": "A"}
doc2: {"num": [1, 2, 3, 5], "type": "B"}
doc3: {"num": [5, 6, 7, 1], "type": "A"}
At the moment, i can do that something like:
db.something.find({"type": "A"}, {"num": 1})
I get something like:
"num": [5, 6, 7, 1]
"num": [3, 10, 25]
But I want to get [1, 3, 5, 6, 7, 10, 25]. (Even better if i get only top N like [1, 3, 5] when N=3)
And I don't care about type of return. And, it's much better i can get new documents with cursor like:
new document 1: {1}
new document 2: {3}
new document 3: {5}
.........
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment