Skip to content

Commit

Permalink
updated dependencies for lint and test
Browse files Browse the repository at this point in the history
  • Loading branch information
chentsulin committed Sep 29, 2018
1 parent c637aaa commit f9cca20
Show file tree
Hide file tree
Showing 3 changed files with 133 additions and 129 deletions.
48 changes: 24 additions & 24 deletions lib/index.js
Expand Up @@ -22,8 +22,8 @@ module.exports = function modelBase (bookshelf, params) {
}

this.validate = this.validate.isJoi
? this.validate.keys(baseValidation)
: Joi.object(this.validate).keys(baseValidation)
? this.validate.keys(baseValidation)
: Joi.object(this.validate).keys(baseValidation)

this.on('saving', this.validateSave)
}
Expand Down Expand Up @@ -104,7 +104,7 @@ module.exports = function modelBase (bookshelf, params) {
*/
create: function (data, options) {
return this.forge(data)
.save(null, options)
.save(null, options)
},

/**
Expand All @@ -119,9 +119,9 @@ module.exports = function modelBase (bookshelf, params) {
update: function (data, options) {
options = extend({ patch: true, require: true }, options)
return this.forge({ [this.prototype.idAttribute]: options.id }).fetch(options)
.then(function (model) {
return model ? model.save(data, options) : undefined
})
.then(function (model) {
return model ? model.save(data, options) : undefined
})
},

/**
Expand All @@ -134,7 +134,7 @@ module.exports = function modelBase (bookshelf, params) {
destroy: function (options) {
options = extend({ require: true }, options)
return this.forge({ [this.prototype.idAttribute]: options.id })
.destroy(options)
.destroy(options)
},

/**
Expand All @@ -146,11 +146,11 @@ module.exports = function modelBase (bookshelf, params) {
*/
findOrCreate: function (data, options) {
return this.findOne(data, extend(options, { require: false }))
.bind(this)
.then(function (model) {
var defaults = options && options.defaults
return model || this.create(extend(defaults, data), options)
})
.bind(this)
.then(function (model) {
var defaults = options && options.defaults
return model || this.create(extend(defaults, data), options)
})
},

/**
Expand All @@ -161,18 +161,18 @@ module.exports = function modelBase (bookshelf, params) {
*/
upsert: function (selectData, updateData, options) {
return this.findOne(selectData, extend(options, { require: false }))
.bind(this)
.then(function (model) {
return model
? model.save(
updateData,
extend({ patch: true, method: 'update' }, options)
)
: this.create(
extend(selectData, updateData),
extend(options, { method: 'insert' })
)
})
.bind(this)
.then(function (model) {
return model
? model.save(
updateData,
extend({ patch: true, method: 'update' }, options)
)
: this.create(
extend(selectData, updateData),
extend(options, { method: 'insert' })
)
})
}
})

Expand Down
10 changes: 5 additions & 5 deletions package.json
Expand Up @@ -25,11 +25,11 @@
"bluebird": "^3.4.1",
"bookshelf": "^0.10.0",
"knex": "^0.11.9",
"chai": "^3.5.0",
"chai": "^4.2.0",
"istanbul": "^0.4.4",
"mocha": "^3.0.0",
"sinon": "^1.17.5",
"sqlite3": "^3.1.4",
"standard": "^7.1.2"
"mocha": "^5.2.0",
"sinon": "^6.3.4",
"sqlite3": "^4.0.2",
"standard": "^12.0.1"
}
}

0 comments on commit f9cca20

Please sign in to comment.