Hello,
I am struggling to retrieve the elements of an array in the customer functions of Realm UI.
I have a simple collection and here is an example of a document
{
"_id" : ObjectId("5f1db4f0a3f141fb2f1e6hfd"),
"_partition" : "My Project",
"online" : [
ObjectId("5ddf98bc5fd87f00175dc6cb"),
ObjectId("5ddf98bc5fd87f00175dc6cc"),
ObjectId("5ddf98bc5fd87f00175dc6cd")
],
"day" : "Monday",
"minute" : 0,
"hour" : 0
}
I want to retrieve the elements inside the ‘online’ array and later run another function over those Object ids that represent the ids of users in another collection.
I am simply doing the following:
exports = async function(){
const cluster = context.services.get("mongodb-atlas");
const myCollection = cluster.db("myDB").collection("myCollection");
const result = await availability.find({ day: "Monday", hour: 0, minute: 0 });
//From here on, nothing is working properly
}
Until now all is good but after that, I am not able to retrieve the elements of the ‘online’ array.
I tried different methods, but everything is giving me “$undefined”: true …
What can I do to retrieve those 3 object ids and save them in a variable?
Please note that I am using the custom functions of the Realm UI. It is a must to use those functions as I am creating a Cron job using Realm.