bookshelf-flexi-where
v0.1.5
Published
Bookshelf plugin for more flexible where statement
Downloads
2
Maintainers
Readme
bookshelf-flexi-where
A more flexible way to build where statements in bookshelf.
Installation
npm i --save bookshelf-flexi-where
Usage
import flexiWhere from 'bookshelf-flexi-where';
// Register the plugin
Bookshelf.plugin(flexiWhere);
const opts = [
{
column: 'email',
operator: 'like',
value: '%tripvisto%',
},
{
column: 'username',
operator: '=',
value: 'wingski',
},
];
User.forge()
.flexiWhere(opts)
.fetchAll()
.then(result => {
expect(result.size(), 1);
expect(result.at(0).get('email')).include('tripvisto');
expect(result.at(0).get('username')).include('wingski');
})
.then(() => done())
.catch(err => done(err));
License
MIT