【发布时间】:2021-01-01 22:50:47
【问题描述】:
我成功地从我的 Mongo DB 中获取了一个文档,但是该文档中的所有内容都显示为未定义。这是一个例子:
...
const user = await UserModel.findById(user_id).exec(); //Getting user normally
console.log(user); // Shows the object normally with the "push_subscriptions" property
console.log(user.push_subscriptions); // Shows undefined
console.log(user.email); //Shows the email normally
...
控制台截图如下:
这是用户架构的“push_subscriptions”部分:
...
push_subscriptions: {
type: Array,
},
...
【问题讨论】:
-
push_subscriptions可以是 gets added later,在console.log(user)之后吗? -
@T.J.Crowder 不,它在我的数据库中
-
很费解....
-
非常不寻常,你能给我们看看Shema吗?
-
@JohnRC 是的,我同意:D。也许它与异步操作或其他什么有关?
标签: javascript node.js mongodb