0

I am running the Node.js + MongDB exercice proposed at https://www.w3schools.com/nodejs/nodejs_mongodb_join.asp

There are two collections, orders and products. After the aggregate, the expected result should be:

[
  { _id: 1, product_id: 154, status: 1, orderdetails: [
    { _id: 154, name: 'Chocolate Heaven' } ]
  }
]

However, in my local instance, I am getting the following result:

[ { _id: 1, product_id: 154, status: 1, orderdetails: [ [Object] ] } ]

What shoud I do in order to get an { _id: 154, name: 'Chocolate Heaven'} instead of an [Object]?

  • 1
    If you are seeing this with console.log try logging with `console.log(JSON.stringify(returnedDataHere));` – bennygenel Sep 09 '17 at 12:35
  • Use console.dir instead of console.log on variables with nested objects and arrays if you want to display them in full in the console. – SylonZero Sep 09 '17 at 20:24

0 Answers0