Skip to content

npatmaja/bookshelf-flexi-where

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

A Bookshelf plugin for more flexible where statements

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published