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

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() { ...@@ -564,24 +564,24 @@ module.exports = (function() {
}).run() }).run()
} }
DAOFactory.prototype.findOrCreate = function (params, defaults) { DAOFactory.prototype.findOrCreate = function (where, defaults) {
var self = this; var self = this;
var where = {}; var params = {};
for (var attrname in params) { for (var attrname in where) {
where[attrname] = params[attrname] params[attrname] = where[attrname]
} }
return new Utils.CustomEventEmitter(function (emitter) { return new Utils.CustomEventEmitter(function (emitter) {
self.find({ self.find({
where: where where: params
}).success(function (instance) { }).success(function (instance) {
if (instance === null) { if (instance === null) {
for (var attrname in defaults) { for (var attrname in defaults) {
where[attrname] = defaults[attrname] params[attrname] = defaults[attrname]
} }
self.create(where) self.create(params)
.success(function (instance) { .success(function (instance) {
emitter.emit('success', instance, true) 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!