Skip to content

Instantly share code, notes, and snippets.

@pyykkis
Last active December 21, 2015 15:49
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 pyykkis/6328802 to your computer and use it in GitHub Desktop.
Save pyykkis/6328802 to your computer and use it in GitHub Desktop.
Streaming mongodb queries
search: ({query: {q}}, res) =>
@collection.then((coll) ->
coll.find(key: new RegExp(q, 'i'))
.sort(_id: -1)
.limit(20)
.stream()
.pipe(JSONStream.stringify())
.pipe(res))
.done()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment