Mongodb 怎么根据value值来定位来操作文档?求帮忙
将要存入DB的数据
store: [ { urlPath: 'server1’ responseTime: 1 count: 1 }, { urlPath: 'server2’ responseTime: 2 count: 2 } ]
在DB中的数据
detail: [ { urlPath: 'server1’ responseTime: 1 count: 1 }, { urlPath: 'server2’ responseTime: 2 count: 2 }, { urlPath: 'server3’ responseTime: 3 count: 3 } ]
我想根据urlPath给相应的responseTime和count都做$inc操作,比如说urlPath:‘server1’ 的responseTime 和count 都 + 1? 这个我该怎么根据值来定位,$inc{}里面该怎么写呢
1 回复
db.tablename.update({urlPath: 'server1'}, {$inc: {'responseTime': 1, 'count': 1}}, false, true);
这个么?