【发布时间】:2013-09-30 12:23:54
【问题描述】:
在我的程序中,通过update(key, doc, upsert=true)写mongodb的十个进程
“key”是 mongodb 索引,但不是唯一的。
查询 = {'hotelid':hotelid,"arrivedate":arrivedate,"leavedate":leavedate}
where = "data.%s" % sourceid
data_value_where = {where:value}
self.collection.update(query,{'$set':data_value_where},True)
“查询” id 不是唯一的索引
我发现有时候更新不是更新存在的数据,而是创建一个新的数据。
我写了一个更新方法返回的日志,返回是“ {u'ok': 1.0, u'err': None, u'upserted': ObjectId('5245378b4b184fbbbea3f790'), u'singleShard': u' rs1/192.168.0.21:10000,192.168.1.191:10000,192.168.1.192:10000,192.168.1.41:10000,192.168.1.113:10000',你'connectionId':1894107,你'n'更新': ': False, u'lastOp': 5928205554643107852L}"
我将更新方法修改为update(query, {'$set':data_value_where},upsert=True, safe=True),但是对于这个问题三是没有变化的。
【问题讨论】:
-
谁对试图提出合法问题但英语打字能力明显有限的人投了反对票?你太无耻了。为什么不帮助 chjuheng 重写它,这样更容易理解?
-
我修改了问题,并在上面写了一些日志。感谢所有重播。