Is it possible to get the model from the document in mongoose?

Assume you have a user variable that is an instance of the User model, but this will work for any mongoose model instance var Model = user.constructor; now you can do Model.find() to run your query and this will work on any collection.

If you need the name of the model, it can be accessed via user.constructor.modelName.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)