Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
bookshelf-json-columns
Advanced tools
This Bookshelf.js plugin enables you to define which model columns have JSON format, preventing manual hook definition for each model with JSON columns.
Install the package via npm
:
$ npm install --save bookshelf-json-columns
Require and register the bookshelf-json-columns plugin:
var bookshelf = require('bookshelf')(knex);
var jsonColumns = require('bookshelf-json-columns');
bookshelf.plugin(jsonColumns);
Define which columns have JSON format with the jsonColumns
class property:
bookshelf.Model.extend({
tableName: 'foo'
}, {
jsonColumns: ['bar', 'biz']
});
If you're using ES6 class syntax, define jsonColumns
as static property:
class Model extends bookshelf.Model {
get tableName() {
return 'foo';
}
static jsonColumns = ['bar', 'biz'];
}
This plugin extends the initialize
and save
methods of Bookshelf's Model
, so if you are also extending or overriding them on your models make sure to call their prototype after your work is done:
bookshelf.Model.extend({
initialize: function() {
// Do some stuff.
store.addModel(this);
// Call the `initialize` prototype method.
bookshelf.Model.prototype.initialize.apply(this, arguments);
},
save: function() {
// Do some stuff.
store.validateModel(this);
// Call the `save` prototype method.
bookshelf.Model.prototype.save.apply(this, arguments);
},
tableName: 'foo'
}, {
jsonColumns: ['bar', 'biz']
});
Contributions are welcome and greatly appreciated, so feel free to fork this repository and submit pull requests.
bookshelf-json-columns supports PostgreSQL, SQLite3 and MySQL. You can find test suites for all these database engines in the test folder.
$ npm test
bookshelf-json-columns enforces linting using ESLint with the Seegno-flavored ESLint config. We recommend you to install an eslint plugin in your editor of choice, although you can run the linter anytime with:
$ eslint src test
Please follow these advices to simplify the pull request workflow:
3.0.0 (2019-12-28)
Closed issues:
Merged pull requests:
FAQs
Parse JSON columns with Bookshelf.js
We found that bookshelf-json-columns demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.