I get this error on updating a record, instance.isNew is set to false before I call save()
errmsg: 'E11000 duplicate key error collection: mydb.mycollection index: date_1 dup key: { : new Date(1552176000000) }'
If I am updating my does mongo care if a key value is equal to what it was before the save is called?
thanks!
dateand you are inserting exactly the same value as an existing document for that field. You cannot do that, and you probably do not need a "unique" index on that field.var instance = new MyModel()is new. TheisNewis simply a flag, but yournew MyModel()returns something with a completely separate_id. Therefore it's an "insert" and not an "update".date: { type: Date, unique: true, required: true },indeed you are right. Hazy day. Thanks @NeilLunn