You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like to generally use the auto-incrementing value when creating new documents. However, if the user chooses to specify an explicit value, I want to use that value instead and also not increment the auto-inc counter. Is that possible without having to first save the document, then manually update and re-save the doc and manually decrement the counter collection again?
The text was updated successfully, but these errors were encountered:
hello @rip32700 I think you can follow what it explained in the Not automatic sequences section of the readme for your use case. Something like this
MySchema=mongoose.Schema({
...otherpropsvalue: Number});// Do not use auto incrementMySchema.plugin(AutoIncrement,{id:'value_counter',inc_field: 'value',disable_hooks: true});// Then, when savingmydoc.save();if(!mydoc.value){mydoc.setNext('value_counter',(err,doc)=>{
...
});}
I would like to generally use the auto-incrementing value when creating new documents. However, if the user chooses to specify an explicit value, I want to use that value instead and also not increment the auto-inc counter. Is that possible without having to first save the document, then manually update and re-save the doc and manually decrement the counter collection again?
The text was updated successfully, but these errors were encountered: