Sunday, 20 September 2020

How do I get the JSON value from a mongoose schema object?

let workers = Worker.find({});workers returns an array of mongoose schema objects, but I want an array of JSON objects instead.How do I go about accomplishing this?// Worker.find({})// .then((worker) => console.log(worker))// .catch((err) => console.log(err))I am only able to print an array of JSON objects but not access them.let arr = []// Worker.find({})// .then((worker) => arr.push(worker))// .catch((err) => console.log(err))// console.log(arr)When I print the arr, I am not getting any output.

Submitted September 21, 2020 at 12:58AM by warlockMathers

No comments:

Post a Comment