1.0.1 • Published 8 years ago
mongoose-find-as-string v1.0.1
mongoose-find-as-string
mongoose-find-as-stringis a Mongoose plugin that enables you to search on every property as string, that means it searches on non-text field types as Dates, Booleans, etc.
Motivation: let's say a user enters 2017 one option is to start searching the Date field using $gt and $lt for that period. But what happens when a user searches for 20 that can match years, months, days, hours, etc. If text indexes, virtual props and extensive aggreate pipelines are giving you a headhache: this plugin is just for you.
Index
Install
npm install mongoose-find-as-string --saveUsage
This plugin must first be added to a schema:
var mongooseAggregatePaginate = require('mongoose-find-as-string');
sampleSchema.plugin(mongooseAggregatePaginate);SampleModel will have a new function called findAsString (e.g. SampleModel.findAsString()).