You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So when you pass a number to an ObjectId, ObjectId treats it as a timestamp. However, an ObjectId is not uniquely defined by a timestamp. Any reason why you're not just passing in the hex string?
The following code does not work. Any bugs or anything wrong?
For sure ids are in the db. But it does not update at all.
var idsObj = [];
var ids = [ 1426879378856, 1426878899305, 1426878875930 ];
_.each(ids, function (id) {
idsObj.push({'_id': new objectID(id._id)});
});
var findQuery = {'$or': idsObj};
db.collection('bands').update(findQuery, {'$set': {updateThis: 'blur blur'}},
{w:"majority", wtimeout:500, j:true, remove:true, upsert:false, multi:t},
function(err, result) {
if (err) {
console.log(err);
}
else {
console.log(result);
}
});
If I run this in the shell, it update all 3 docs.
db.collection('bands').update({$or: [{'_id': ObjectId('550c7393e50a63c0d712d25e')},
{'_id': ObjectId('550c71b4e50a63c0d712d25d')},
{'_id': ObjectId('550c7196e50a63c0d712d25c')}] },
{$set : {updateThis: 'blur blur' } },
{w:"majority", wtimeout:500, j:true, remove:true, upsert:false, multi:true}
)
The text was updated successfully, but these errors were encountered: