Mongoose.js: is it possible to find out if the field was filled

I have a document with a reference field objectId that I can fill out.

Is there a known way to find out if a field has already been filled?

+4
source share
1 answer

You can use the method document.populated(path)( as described here ). It returns the _id used for the aggregate, and undefinedif the field was not filled.

+8
source

Source: https://habr.com/ru/post/1538191/


All Articles