In my function below I am trying to get all the ObjectIDs in ‘mycollection’. Since the find function returns an EJSON object when I log the output I just see ‘{ }’. I cannot manage to output the ObjectIDs, can anyone point me in the right direction please?
(I know the result is not empty by the way, as it outputs the correct JSON-looking object in the console)
exports = async function(){
const mongodb = context.services.get("mongodb-atlas");
const collection = mongodb.db("mydatabase").collection("mycollection");
var result = {};
var resultJson = {};
try { result = await collection.find({}, {_id:1})
resultJson = JSON.stringify(result);
}
catch (e){
console.log(e);
}
console.log('res', resultJson)
return result;
};