I have this schema (for example):
var WordSchema = new Schema({
word: {
type: String
}
});
module.exports = mongoose.model('Word', WordSchema);
How I can add new property when create new doc in mongoose? something like this:
let Word = require("../models/word");
let initWord = "hello";
word = new Word({
word: initWord,
length: initWord.length
});
word.save(function(error) {
if (error) {
//some code
} else {
//some code
}
});
But this does not work