mongoose-fuzzy-search-next
v1.0.13
Published
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
Downloads
176
Maintainers
Readme
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.