【发布时间】:2017-03-16 18:10:33
【问题描述】:
大家好,我正在做流星 mongo db,我使用 findAndModify 包
Ips.findAndModify({
//Find the desired document based on specified criteria
query: {
"ipAdr": clientIp,
connections: {
$elemMatch: {
connID: clientConnId
}
}
},
//Update only the elements of the array where the specified criteria matches
update: {
$push: {
'connections': {
vid: result.data.vid,
firstName: result.data.properties.firstname.value,
lastName: result.data.properties.lastname.value
}
}
}); //Ips.findAndModify
所以我找到了我需要的元素,但是我的信息被推送到整个连接数组,但我想将我的信息推送到那个特定的元素中。我应该在这里做什么?我试过了
$push: {
'connections.$': {
vid: result.data.vid,
但它给出了错误。 请帮忙。
【问题讨论】:
-
你遇到了什么错误??
标签: arrays node.js mongodb meteor