Guest User

Untitled

a guest
Jul 17th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. find : (col, arguments..., callback) ->
  2. if @connected
  3. if !callback and typeof callback != 'function'
  4. @handleCallback()
  5. return true
  6. if !col
  7. return true
  8. @handleCollection()
  9. if col and callback
  10. @db.collection col, (e, collection) =>
  11. if e
  12. @emit 'error', e
  13. @logError e
  14. callback e, null
  15. if collection
  16. collection.find arguments, (e, cursor) =>
  17. if e
  18. @emit 'error', e
  19. @logError e
  20. callback e, null
  21. if cursor
  22. cursor.toArray (e, docs) =>
  23. if e
  24. @emit 'error', e
  25. @logError e
  26. callback e, null
  27. if docs
  28. @logInfo "Fetched all doc(s)! Command: find"
  29. callback null, docs
Add Comment
Please, Sign In to add comment