Node.js - Get the SchemaObject without querying?
-
26-10-2019 - |
سؤال
Givem that I have the Subdomain ID
, do I need to do a find in order to get the Subdomain object?
e.g: I have to do Subdomain.find {_id: item.subdomain_id}, (err, subdomain) ->
in order to get the object subdomain? It'd be much better just to do item.subdomain
.
Thanks!
المحلول
If you only have the _id you're still going to have to look-up the document itself. In Mongoose this can be done with Model.findById as described here: http://mongoosejs.com/docs/finding-documents.html#Model.findById
لا تنتمي إلى StackOverflow