Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bookshelf-modelbase

Package Overview
Dependencies
Maintainers
2
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bookshelf-modelbase - npm Package Compare versions

Comparing version 2.9.0 to 2.10.0

12

lib/index.js

@@ -50,2 +50,4 @@ var extend = require('xtend')

if (validation.error) {
validation.error.tableName = this.tableName
throw validation.error

@@ -70,2 +72,12 @@ } else {

/**
* Find a model based on it's ID
* @param {String} id The model's ID
* @param {Object} [options] Options used of model.fetch
* @return {Promise(bookshelf.Model)}
*/
findById: function (id, options) {
return this.findOne({ [this.prototype.idAttribute]: id }, options)
},
/**
* Select a model based on a query

@@ -72,0 +84,0 @@ * @param {Object} [query]

2

package.json
{
"name": "bookshelf-modelbase",
"version": "2.9.0",
"version": "2.10.0",
"description": "Extensible ModelBase for bookshelf-based model layers",

@@ -5,0 +5,0 @@ "main": "./lib",

@@ -112,2 +112,16 @@ # bookshelf-modelbase

### model.findById
```javascript
/**
* Find a model based on it's ID
* @param {String} id The model's ID
* @param {Object} [options] Options used of model.fetch
* @return {Promise(bookshelf.Model)}
*/
findById: function (id, options) {
return this.findOne({ [this.prototype.idAttribute]: id }, options)
}
```
#### model.findOne

@@ -114,0 +128,0 @@

@@ -90,6 +90,12 @@ /* global describe, before, after, beforeEach, it */

it('should error on invalid attributes', function () {
var error
specimen.set('first_name', 1)
expect(function () {
try {
specimen.validateSave()
}).to.throw(/first_name must be a string/)
} catch (err) {
error = err
}
expect(error.tableName).to.equal('test_table')
})

@@ -140,2 +146,16 @@

describe('findById', function () {
it('should find a model by it\'s id', function () {
var created
return SpecimenClass.create({ first_name: 'yo' })
.then(function (model) {
created = model
return SpecimenClass.findById(model.id)
})
.then(function (model) {
expect(model.id).to.deep.equal(created.id)
})
})
})
describe('findOne', function () {

@@ -142,0 +162,0 @@ it('should return a model', function () {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc