My model:
const userSchema = mongoose.Schema({
_id: mongoose.Types.ObjectId,
name: { type: String, required: true, maxlength: 32, trim: true },
email: { type: String, required: true, trim: true, unique: true },
words: [Object]
}
, { timestamps: true }
)
I want to add an object to the words array if it doesn't exist otherwise update the value of repeat_count.
This is the word object I want to add:
var word = { word : "hello" , repeat_count : "12" }
Is there any built-in function to do so?