bp-searchterms

1.0.3 • Public • Published

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 } }
  ]
}

Readme

Keywords

Package Sidebar

Install

npm i bp-searchterms

Weekly Downloads

4

Version

1.0.3

License

ISC

Unpacked Size

2.82 kB

Total Files

3

Last publish

Collaborators

  • beeplaced