Created
July 17, 2015 05:57
-
-
Save bells17/64aca65bdd817dc53b93 to your computer and use it in GitHub Desktop.
mongooseでSchema定義してないpropertyに値をセットする ref: http://qiita.com/bells17/items/cafe8f0b3e285e9e8ab4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var somethingSchema = new Schema({ | |
field: String | |
}); | |
var Something = mongoose.model('Something', somethingSchema); | |
var something = new Something(); | |
something.not_defined_field = 'Not defined field value'; | |
something('not_defined_field'); // -> undefined | |
something.not_defined_field; // -> undefined | |
something.set('not_defined_field', 'Not defined field value', { strict: false }); | |
something('not_defined_field'); // -> 'Not defined field value' | |
something.not_defined_field; // -> undefined | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment