mongoose-plugin-encode-keys
Add support for unsafe chars inside MongoDB field names (like .
or keys starting with $
)
Quickstart
- Load the plugin inside your schema
import {Schema} from 'mongoose';
import encodeKeysPlugin from 'mongoose-plugin-encode-keys';
const schema = new Schema({
name: {type: String, required: true},
content: {type: Object, default: {}}
});
// Support exotic payload keys
schema.plugin(encodeKeysPlugin, {fields: ['content']});
export default schema;
Testing
- You can quickly start hacking around
git clone -o github git@github.com:mgcrea/mongoose-plugin-encode-keys.git
cd mongoose-plugin-encode-keys
npm i
npm test