Tuesday, 25 April 2017

Executing same query gives "FailedToParse" error in nodejs

Database structure is;

{ "comment" : "test" }
{ "comment" : "test" }
{ "comment" : "test" }
{ "comment" : "test" }
{ "comment" : "test" }
{ "comment" : "test" }
{ "comment" : "test" }
{ "comment" : "test" }
{ "comment" : "test" }
{ "comment" : "test" }

In mongoshell the query,

db.collection.find({}, {comment: 1, _id: 0})

lists the documents.

However, when I run the same query in nodejs it gives me an error as;

{
  "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"
}

I don't understand what can be the problem?

I am aware that the question doesn't make sense, however,meaninglessly this is what I have. Is it about mongo versions or what?



via mmu36478

No comments:

Post a Comment