Javascript Meteor Mongo获得特定值
我拥有具有以下值的集合:Javascript Meteor Mongo获得特定值,javascript,mongodb,meteor,Javascript,Mongodb,Meteor,我拥有具有以下值的集合: Plans.insert({ location, address, date, time, notes, createdAt: new Date(), // current time owner: Meteor.userId(), username: Meteor.user().username, attendees: [ { user: Meteor.user().username; },
Plans.insert({
location,
address,
date,
time,
notes,
createdAt: new Date(), // current time
owner: Meteor.userId(),
username: Meteor.user().username,
attendees: [
{
user: Meteor.user().username;
},
{
user: Meteor.user().username;
},
],
});
但我想知道如何才能获得数组
与会者的具体值
到目前为止,我已经尝试了Plans.findOne({u id:{attenders:[{user:Meteor.user().username},],})代码>但结果是未定义的
我还想知道如何获得每个人的数值,例如与会者[0]
和与会者[1]
您需要使用$elemMatch
Plans.findOne({attendees: {$elemMatch: {user: 'ABC'}}};
“如何获得阵列与会者的特定值”-意味着什么?获取在Attendeers数组中具有特定值的文档?是否有方法获取所有具有该值的集合$elemMatch
只检索第一个匹配项,但我需要所有适用的内容。你是说关于文档,没有收集仪式?是的,对不起,我指的是文档。