db.mongo.insert({name:'mongo'});>vart=db.mongo.findOne();>t{"_id":ObjectId("5141b98723616e67f947f356"),"name":"mongo"}>vard=t>d{"_id":ObjectId("5141b98723616e67f947f356"),"name":"mongo"}>d.password=123123>d{ "_id":ObjectId("5141b98723616e67f947f356"), "name":"mongo", "password":123}>t{ "_id":ObjectId("5141b98723616e67f947f356"), "name":"mongo", "password":123}问题1vard=t是引用赋值吗如果是的话,怎么样不使用引用赋值deleted.passwordtrue>d{"_id":ObjectId("5141b98723616e67f947f356"),"name":"mongo"}>d.password=124124>d{ "_id":ObjectId("5141b98723616e67f947f356"), "name":"mongo", "password":124, "password":124}问题2我执行deleted.password返回true说明已经删除,为什么我再执行d.password=124会执行两次添加>d{ "_id":ObjectId("5141b98723616e67f947f356"), "name":"mongo", "password":124, "password":124}刚开始接触不是很明白,希望有知道的说明下原因
1 回答
繁星coding
TA贡献1797条经验 获得超4个赞
第一个问题...因为两个条目有同样的ObjectId所以视为是同一条...虽然事实上不是引用赋值但你可以这么理解...第二个问题无法复现所以不知...
添加回答
举报
0/150
提交
取消