使用findone重写findById

This commit is contained in:
绯村月
2014-02-24 10:33:01 +08:00
parent fb61cab653
commit 04f8ef3916

View File

@@ -105,10 +105,4 @@ module.exports = class Model
# id为string
@findById: (id, opts = {}, callback) ->
if _.isFunction opts
callback = opts
opts = {}
@collection().findOne {_id: id}, (err, doc) =>
throw err if err
result = @create doc
callback err, result
@findOne {_id: id},opts,callback