不要怂,就是干,撸起袖子干!

Commit e3db6535 by Elliot Foster

Increase similarity to original code

1 parent 9e0c5b14
Showing with 7 additions and 7 deletions
......@@ -564,24 +564,24 @@ module.exports = (function() {
}).run()
}
DAOFactory.prototype.findOrCreate = function (params, defaults) {
DAOFactory.prototype.findOrCreate = function (where, defaults) {
var self = this;
var where = {};
for (var attrname in params) {
where[attrname] = params[attrname]
var params = {};
for (var attrname in where) {
params[attrname] = where[attrname]
}
return new Utils.CustomEventEmitter(function (emitter) {
self.find({
where: where
where: params
}).success(function (instance) {
if (instance === null) {
for (var attrname in defaults) {
where[attrname] = defaults[attrname]
params[attrname] = defaults[attrname]
}
self.create(where)
self.create(params)
.success(function (instance) {
emitter.emit('success', instance, true)
})
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!