0

Does a toString type function exists for mongodb object. For example I have a mongo object and I access it using mongoose in node.js.

x = new Type();

I want to call something like

console.log(x);

Which displays a specific field defined in toString of x. This isn't equivalent to object._id.toString() because x is not stored in the database.

saurabh
  • 293
  • 2
  • 7
  • 19
  • What exactly do you want to achieve? – Amiram Korach Aug 23 '16 at 06:49
  • lets say my model is x = { name: " asdasdas ", lastname: "asdasd", } I want a toString function which when called gives me only name like function toString(){ return name } This should return only name or any field I define in toString() I hope you got my point. Similar to java toString or python __str__() – saurabh Aug 23 '16 at 07:09
  • http://stackoverflow.com/questions/6307514/is-it-possible-to-override-javascripts-tostring-function-to-provide-meaningfu – Amiram Korach Aug 23 '16 at 07:31

0 Answers0