0.1.0 • Published 8 years ago
knex-doc-filter v0.1.0
knex-doc-filter
MongoDB query documents in knex.js
Creates a knex.js filter using MongoDB query document
Operators
$and, $or, $nor, $eq, $ne, $regex, $gt, $gte, $lt, $lte, $in, $nin, $not
Example (ES6)
import Knex from 'knex'
import docFilter from 'knex-doc-filter'
let knex = Knex({
client: 'mysql',
connection: {
host: '127.0.0.1',
user: 'root',
password: 'password',
database: 'test'
}
})
let selection = knex('animals')
let query = {
$and: [
{ owner: { $eq: 'you' } },
{ name: 'Cat' }
]
}
docFilter(selection, query).then(console.log, console.error)API
docfilter (selection, query) => KnexQueryBuilder
selection- query selection to build fromquery- document query (seemongo documentation)
Notes
$regex- uses T-SQLLIKE(seeLIKE documentation)
0.1.0
8 years ago