You can check the object’s prototype via the instanceof operator to confirm it’s an instance of your mongoose model. Using the example schema from mongoosejs.com:
if (obj instanceof Cat) {
// yes, it's a mongoose Cat model object
...
}
You can check the object’s prototype via the instanceof operator to confirm it’s an instance of your mongoose model. Using the example schema from mongoosejs.com:
if (obj instanceof Cat) {
// yes, it's a mongoose Cat model object
...
}