I m using mongodb native drive to get the cursor of a query result. I m using a 'comment' field which is basically a string below is the code snippet i m using
let leve1_n = 'labreports';
let matchLabReports = { level1_n: "labreports" };
let sortCondition = { _id: 1 };
let projection = {comment : 1 , color: 1, value: 1, value_n: 1, value_d: 1, rangeStart: 1, rangeEnd: 1, level2: 1 };
let collectionName = collectionNames.biomarkerAggregations;
let cursor = dbModule.findCursorSort(dbModule.getDbHandle(dbName), collectionName, matchLabReports, projection,sortCondition);
cursor.forEach(doc => {
// Lambda Expression
// Do something with doc.
})
but this is giving me error like..
name: 'MongoError', message: 'Failed to parse: comment: 1. \'comment\' field must be of BSON type string.', ok: 0, errmsg: 'Failed to parse: comment: 1. \'comment\' field must be of BSON type string.', code: 9, codeName: 'FailedToParse' }
After removing comment field from the project everything is working fine. Any help would be appreciated.
via Brijesh Prajapati
No comments:
Post a Comment