測(cè)試數(shù)據(jù):{"_id":ObjectId("4b97e62bf1d8c7152c9ccb74"),"title":"ABC","comments":[{"by":"joe","votes":3},{"by":"jane","votes":7}]}執(zhí)行更新語句:語句一:db.mydb.update({title:"ABC"},{$inc:{"comments.$.votes":1}},0,1)執(zhí)行報(bào)錯(cuò):Cannotapplythepositionaloperatorwithoutacorrespondingqueryfieldcontaininganarray.語句二:db.mydb.update({"comments.by":"joe"},{$inc:{"comments.$.votes":1}},0,1)執(zhí)行結(jié)果正常請(qǐng)問是怎么回事?
mongodb "$" 操作符問題
躍然一笑
2019-04-23 15:36:04