Skip to content

Instantly share code, notes, and snippets.

@jkeskikangas
Last active December 21, 2015 15:49
Show Gist options
  • Select an option

  • Save jkeskikangas/6328802 to your computer and use it in GitHub Desktop.

Select an option

Save jkeskikangas/6328802 to your computer and use it in GitHub Desktop.

Revisions

  1. Jarno Keskikangas revised this gist Aug 24, 2013. 1 changed file with 7 additions and 7 deletions.
    14 changes: 7 additions & 7 deletions search.coffee
    Original file line number Diff line number Diff line change
    @@ -1,9 +1,9 @@
    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))
    @collection.then((coll) ->
    coll.find(key: new RegExp(q, 'i'))
    .sort(_id: -1)
    .limit(20)
    .stream()
    .pipe(JSONStream.stringify())
    .pipe(res))
    .done()
  2. Jarno Keskikangas revised this gist Aug 24, 2013. 1 changed file with 7 additions and 7 deletions.
    14 changes: 7 additions & 7 deletions search.coffee
    Original file line number Diff line number Diff line change
    @@ -1,9 +1,9 @@
    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))
    @collection.then((coll) -> coll
    .find(key: new RegExp(q, 'i'))
    .sort(_id: -1)
    .limit(20)
    .stream()
    .pipe(JSONStream.stringify())
    .pipe(res))
    .done()
  3. Jarno Keskikangas revised this gist Aug 24, 2013. 1 changed file with 5 additions and 5 deletions.
    10 changes: 5 additions & 5 deletions search.coffee
    Original file line number Diff line number Diff line change
    @@ -1,9 +1,9 @@
    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))
    .sort(_id: -1)
    .limit(20)
    .stream()
    .pipe(JSONStream.stringify())
    .pipe(res))
    .done()
  4. Jarno Keskikangas created this gist Aug 24, 2013.
    9 changes: 9 additions & 0 deletions search.coffee
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    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()