Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- find : (col, arguments..., callback) ->
- if @connected
- if !callback and typeof callback != 'function'
- @handleCallback()
- return true
- if !col
- return true
- @handleCollection()
- if col and callback
- @db.collection col, (e, collection) =>
- if e
- @emit 'error', e
- @logError e
- callback e, null
- if collection
- collection.find arguments, (e, cursor) =>
- if e
- @emit 'error', e
- @logError e
- callback e, null
- if cursor
- cursor.toArray (e, docs) =>
- if e
- @emit 'error', e
- @logError e
- callback e, null
- if docs
- @logInfo "Fetched all doc(s)! Command: find"
- callback null, docs
Add Comment
Please, Sign In to add comment