[英]getting error while executing mongo command
I have a created a collection with following command: 我使用以下命令创建了一个集合:
db.device_states.documentKey.insert({"device":"nest_kitchen_thermo"})
When I try to execute below command I get an error: 当我尝试执行以下命令时,出现错误:
db.device_states.watch( {
$match: {
"documentKey.device": {
$in : [ "nest_kitchen_thermo"]
},
operationType: "insert"
}
});
syntax ERROR: missing:after property id: 语法错误:缺少:属性ID之后:
The updated collection looks like that: 更新后的集合如下所示:
{
_id: <resume_token>,
operationType: 'insert',
ns: {db:'example',coll:"device_states"},
documentKey: { device:'nest_kitchen_thermo'},
fullDocument: {
_id : ObjectId(),
device: 'nest_kitchen_thermo',
temp: 68
}
}
In Mongo shell, there is no such querying attribute watch
. 在Mongo Shell中,没有这样的查询属性watch
。 $match is part of aggregation pipeline and it should be used within the aggregate operation. $ match是聚合管道的一部分,应在聚合操作中使用。
Modified query(Mongo Shell) is 修改后的查询(Mongo Shell)为
db.device_states.documentKey.aggregate([
{ $match:
{
"device": { $in: ["nest_kitchen_thermo"] },
operationType: "insert"
}
}
]);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.