mongoose-find-as-string
v1.0.1
Published
Mongoose plugin that let you query every field as string
Maintainers
Readme
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()).
