I'm trying to get a single document from a mongodb collection and use that document as an object in javascript. The problem is that the json that I need to store it as a plain object in javascript only comes when I call it from a response.json(doc)
and I can't access that doc outside the function. All the info I found is so confusing!
Is it possible to have something like this:
var a = mongoose.model('collectionName').findOne() //etc.
Just get the whole document and transform it into a javascript object accessible in the global scope, so I can get properties from a
whenever I please.