1.1.1 • Published 7 years ago

mongoose-plugin-encode-keys v1.1.1

Weekly downloads
1
License
MIT
Repository
github
Last release
7 years ago

mongoose-plugin-encode-keys

npm version license build status dependencies status devDependencies status Codacy Badge npm downloads

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