1.0.2 • Published 5 years ago

knex-filter v1.0.2

Weekly downloads
22
License
MIT
Repository
github
Last release
5 years ago

knex-filter

Declarative filtering for knex.js.

Build Status Coverage Status

NPM

Installation

npm i knex-filter --save

Usage

var filter = require('knex-filter').filter;

knex('mytab')
	.where(filter({
		a: 'b',
		'c >': 12,
		'd in': [1, 2, 3],
		e: null,
		not: { f: null },
		or: {
			k: 1,
			'm like': '%Bob%'
		}
	}))
	.then(console.log);

Motivation

Imagine you have page with filterable table, user changes state of your filter controls and presses "apply": you need to pass that filter to backend to obtain filtered set from it. I'm sure you had such case. Was it tedious to walk trough query string and imperatively build your query using knex.js? Forget it, you can now provide filter object from your frontend to your backend and apply it with no effort!

License

MIT

1.0.2

5 years ago

1.0.1

5 years ago

0.1.3

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

9 years ago