标签: mongoose
我有一个带有objectId引用字段的文档,可以填充。
是否有已知的方法来确定该字段是否已填充?
答案 0 :(得分:12)
您可以使用document.populated(path)方法(as documented here)。它返回用于填充的_id,如果尚未填充该字段,则返回undefined。
document.populated(path)
undefined