Creating a dictionary schema with Mongoose
There is no support for dictionary in mongoose
. Field name can't be dynamic in a schema. You should go with a raw object(embedded document) and implement it as a dictionary. But there will be no validation from mongoose
and use markModified before saving whenever you have changed that field
var fooSchema=mongoose.Schema({name:String, dic:{}});
//dic is your dictionary
Update: from 5.1 mongoose have a Map type: https://mongoosejs.com/docs/schematypes.html#maps