mongoose-fuzzy-search-next

1.0.13 • Public • Published

mongoose-fuzzy-search-next

This is a simple fuzzy search for mongodb with the help of this package you can easily search mongodb document by single or multiple Key

Any query

contact me on Linkedin kundan kumar .

Installation

Use the package manager mongoose-fuzzy-search-next to install.

npm i mongoose-fuzzy-search-next

Your Collection

Product collection
Object key Pname, Description 
{
    "_id" : ObjectId("6017a848a506280648cac2b3"),
    "Pname" : "Laptop",
    "Description" : "Lenovo i7 MD Sliver"
}

Example-1 with mongoose



const {FuzzySearch}=require('mongoose-fuzzy-search-next');
const data=await PRODUCT_TABLE.find(FuzzySearch(['Pname','Description'],'my search keyword'));


Example-2 with Condition



const {FuzzySearch}=require('mongoose-fuzzy-search-next');
const data=await PRODUCT_TABLE.find({$and:[FuzzySearch(['Pname','Description'],'laptop'),{Price:{$gt:12500}}]});



Example-3 with search number 452015



const {FuzzySearch}=require('mongoose-fuzzy-search-next');
const data=await PRODUCT_TABLE.find(FuzzySearch(['PinCode','Description'],'452015'));



Example-4 with aggregation



const {FuzzySearch}=require('mongoose-fuzzy-search-next');
 const data=await PRODUCT_TABLE.aggregate([
   {$match:{$and:[
   FuzzySearch(['Pname'],'oil'),
   {Price:{$gt:0}}]
  }}
]);



Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

Package Sidebar

Install

npm i mongoose-fuzzy-search-next

Weekly Downloads

20

Version

1.0.13

License

ISC

Unpacked Size

3.38 kB

Total Files

3

Last publish

Collaborators

  • onlykundan