Is there a way to find out if a record "is new" (has not been save yet) in the pre save callback of mongoose model schema?
Yes, there's an isNew
boolean property on a model instance that indicates that. Access it as this.isNew
from your pre save middleware.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With