After executing a lengthy MongoDB query, I have obtained the result:
const data = collection.find({}).project({ name: 1 }).toArray()
The type of this result is Promise<Document[]>
I attempted to perform a transformation on it, but encountered difficulties:
let transformedData = data.map((item) => {item._id, { name: item.name }})
In Vapor / Swift, there exists a map
function for promises as well. Is there a similar functionality in JS / TS?
Is there a way to apply additional operations on the Promise<Document[]>
?