mirror of
https://github.com/HackPlan/RootPanel.git
synced 2026-03-29 16:48:02 +08:00
分离出insert,写操作采用w:1
This commit is contained in:
@@ -23,8 +23,8 @@ module.exports = class Model
|
||||
get : (attr) ->
|
||||
@data[attr]
|
||||
|
||||
save : (data, callback) ->
|
||||
@collection().insert data, {}, (err, docs) =>
|
||||
insert : (data, callback) ->
|
||||
@collection().insert data, {w:1}, (err, docs) =>
|
||||
throw err if err
|
||||
if callback
|
||||
results = []
|
||||
@@ -35,6 +35,8 @@ module.exports = class Model
|
||||
results = @create docs[0]
|
||||
callback err, results
|
||||
|
||||
update : (newObj , opts = {},callback) ->
|
||||
|
||||
@find : (data, opts = {}, callback = null) ->
|
||||
if _.isFunction data
|
||||
callback = data
|
||||
|
||||
@@ -20,4 +20,4 @@ module.exports = class User extends Model
|
||||
setting: {}
|
||||
attribure: {}
|
||||
tokens: []
|
||||
@save data, callback
|
||||
@insert data, callback
|
||||
|
||||
Reference in New Issue
Block a user