Skip to content

Commit

Permalink
Merge pull request #67 from chentsulin/update-lint-test-deps
Browse files Browse the repository at this point in the history
updated dependencies for lint and test
  • Loading branch information
bsiddiqui committed Feb 24, 2019
2 parents 30c2852 + 9cb3ccf commit 9c6f553
Show file tree
Hide file tree
Showing 4 changed files with 136 additions and 130 deletions.
4 changes: 3 additions & 1 deletion .travis.yml
@@ -1,6 +1,8 @@
language: node_js
node_js:
- '6.3.1'
- '10'
- '8'
- '6'
after_script:
- npm install -g codeclimate-test-reporter
- CODECLIMATE_REPO_TOKEN=be81a850806bfaf0ea98cbd38daef658481d1bbcf04886de925b8c043eb0c20e codeclimate < ./coverage/lcov.info
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 9c6f553

Please sign in to comment.