1.0.3 • Published 7 months ago

bp-searchterms v1.0.3

Weekly downloads
-
License
ISC
Repository
github
Last release
7 months ago

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

7 months ago

1.0.2

9 months ago

1.0.1

9 months ago

1.0.0

9 months ago