【发布时间】:2014-07-02 20:29:50
【问题描述】:
我的 mongodb 中的用户有以下数据结构:
{
_id: "someId",
profile: {
username: "oliv",
friendRequests: [
{ fromUserId: "anId", accepted: false, created: "someDate"},
{ fromUserId: "otherId", accepted: true, created: "otherDate"}
]
}
我想检索在我的登录用户的 friendsRequested 中引用的用户对象。 所以我尝试了这样的事情:
Meteor.users.find({_id: {$in: Meteor.user().profile.friendRequests.fromUserId}});
// FYI: Meteor.users is the collection and Meteor.user() retrieves the current user
但它不起作用。我假设这是因为嵌套数组。
有什么方法可以告诉 mongo 遍历 fromUserId 之类的吗?
谢谢
【问题讨论】:
标签: javascript arrays mongodb meteor