测试数据:{"_id":ObjectId("4b97e62bf1d8c7152c9ccb74"),"title":"ABC","comments":[{"by":"joe","votes":3},{"by":"jane","votes":7}]}执行更新语句:语句一:db.mydb.update({title:"ABC"},{$inc:{"comments.$.votes":1}},0,1)执行报错:Cannotapplythepositionaloperatorwithoutacorrespondingqueryfieldcontaininganarray.语句二:db.mydb.update({"comments.by":"joe"},{$inc:{"comments.$.votes":1}},0,1)执行结果正常请问是怎么回事?
慕少森
德玛西亚99
相关分类