Details
Description
_massageObject (used by db.foo.find() and db.foo.remove()) converts a 24 char string into { _id: "..." }. Surely the intention behind the length == 24 check is to convert the string into the corresponding ObjectId()?
src/mongo/shell/collection.js:134-158
DBCollection.prototype._massageObject = function( q ){
|
if ( ! q )
|
return {};
|
|
var type = typeof q;
|
|
if ( type == "function" )
|
return { $where : q };
|
|
if ( q.isObjectId )
|
return { _id : q };
|
|
if ( type == "object" )
|
return q;
|
|
if ( type == "string" ){
|
if ( q.length == 24 )
|
- return { _id : q };
|
+ return { _id : ObjectId( q ) };
|
|
return { $where : q };
|
}
|
|
throw Error( "don't know how to massage : " + type );
|
|
} |