-1
I’m doing a database search (mongoDB) so it returns me an array, I just wanted to be picking up an array object but I’m not getting it.
app.get("/", (req, res)=>{
Gift.find().lean().then(gifts =>{
res.render("loja/index", {gifts: gifts})
console.log(gifts._id)
})
})
I was able to capture that value using just findOne, in this case, what exactly I would have to be doing so I could be capturing all the _id of my documents?
I understood, in the case, from what I understood the
distinct
returns distinct values from fields, i.e., Gifts. _id was an example, but if I wanted to be taking the value of Gifts.value to so perform a sum of such, this would not fit, because it can contain several objects with the same value, so I understood that would be basically what occurs, correct me if I’m wrong on this issue.– André Cabral
Yes, it will bring only the selected fields, as far as I could see it was what you wanted. Take a look at these answers link.
– Horácio Pedrosa