bp-searchterms
v1.0.3
Published
build searchterms for object oriented search e.g. mongoose
Downloads
3
Readme
searchterms
build searchterms for object oriented search e.g. mongoose
Table of Contents
Installation
$ npm i searchterms
Build $and Statements
calling andStatements
const searchterms = require('searchterms')
const instance = new searchterms()
const base = [
{ 'status.status': { $ne: 99 } },
{ supplier: { $ne: '' } }
]
const match = instance.andStatements({ base, fieldToSearch: 'index', searchTerm: 'Alles und (nichts) und !"§$ VIELES' })
will return
{
'$and': [
{ 'status.status': { '$ne': 99 } },
{ supplier: { '$ne': '' } },
{ index: { '$regex': /alles/im } },
{ index: { '$regex': /und/im } },
{ index: { '$regex': /\(nichts\)/im } },
{ index: { '$regex': /und/im } },
{ index: { '$regex': /!"§$/im } },
{ index: { '$regex': /vieles/im } }
]
}