Skip to content

elbuo8/mongoose-immutable

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Mongoose Immutable

Allow your schemas to have immutable properties!

Install

npm install mongoose-immutable --save

Example

var immutablePlugin = require('mongoose-immutable');

var testSchema = new Schema({
  testField: {type: String, immutable: true},
  testDefaultField: {type: String, default: 'test', immutable: true}
});
testSchema.plugin(immutablePlugin);

var Model = mongoose.model('Test', testSchema);
testModel = new Model({
  testField: 'test'
});

Now every attempt to change the value of those labeled immutable will be futile.

Enjoy

About

Make immutable fields in Mongoose

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published