Provides Mongoose support for storing RegExp
.
Example:
var mongoose = require('mongoose')
require('mongoose-regexp')(mongoose);
var mySchema = Schema({ reg: RegExp });
var M = mongoose.model('RegExp', mySchema);
var m = new M;
m.reg = /^mongodb/i;
m.save(function (err) {
M.findById(m._id, function (err, doc) {
var ok = doc.reg.test("MongoDB allows storing RegExps!");
console.log(ok); // true
});
});
npm install mongoose-regexp
There are no guarantees that RegExp
s created and stored using another driver and retreived using this
module will compile or behave the same as originally intended. This module works best when it is known
that RegExp
s stored and retrevied were generated in Node.js.