I have seen many answers to my question but they all involve console.log. I do not need to write them to a console. I need to use the array outside of the promise scope.
db.collection("star").find().toArray (err,result) -> console.log result
i need to use the result out here. I need the array of objects here. I do not need to write to a log. I need for the execution to wait for the data and return it like this:
stars = db.collection("star").find().toArray (err,result) -> return result