when using findAndModify and trying to remove the id field with {fields: {_id, 0}}
I'm getting an error:
uncaught exception: findAndModifyFailed failed: "exception: assertion db/../util/../util/../db/../bson/bsonobjbuilder.h:112"
To reproduce:
db.jobs.save( {
name: "Biz report",
inprogress: false, priority:1,
tasks : [ "run sales report", "email report" ]
} );
// without fields it works:
job = db.jobs.findAndModify({
query:
,
sort :
,
update: {$set: {inprogress: true, started: new Date()}},
new: true
});
// works with fields too
job = db.jobs.findAndModify({
query:
,
sort :
,
update: {$set: {inprogress: true, started: new Date()}},
fields:
,
new: true
});
// find works when using {_id: 0} in fields:
db.jobs.find(
,
{name:1, _id: 0})
// findAndModify fail when using {_id, 0} in fields:
job = db.jobs.findAndModify({
query:
,
sort :
,
update: {$set: {inprogress: true, started: new Date()}},
fields:
,
new: true
});
- duplicates
-
SERVER-2626 Excluding _id field doesn't work with FindAndModify
- Closed