Hey guys,
So I am running into an issue. I am attempting to extract a Object, from an array column, in an Object Table on the Database. I have run the cloud function as it is intended, and have done so with other attributes. I cannot seem to figure it out. This is my cloud function.
Moralis.Cloud.define(“getTokens”, async () => {
const query = new Moralis.Query(“Tokens”);
query.equalTo(“token”);
const count = await query.count();
query.limit(count);
const results = await query.find();
let sum = [];
for (let i = 0; i < results.length; ++i) {
await sum.push({
“Name”: results[i].get(“Name”),
“Symbol”: results[i].get(“Symbol”),
“Address”: results[i].get(“Address”),
“Logo”: results[i].get(“Logo”),
“Type”: results[i].get(“Type”),
“LastPrice”: results[i].get(“LastPrice”),
“objectId”: results[i].get(“objectId”),
“Chain”: results[i].get(“Chain”),
“Pool”: results[i].get(“Pool”),
“Description”: results[i].get(“Description”),
“Website”: results[i].get(“Website”),
“ProfilePic”: results[i].get(“ProfilePic”),
“Pictures”: results[i].get(“Pictures”),
“Video”: results[i].get(“Video”),
“Announcements”: Object.keys(results[i].get(“Announcements”)).map((announcement) => { title: announcement.title, description: announcement.description},
});
}
return sum;
});
All work except Announcements. I have tried mapping it a dozens of different ways, and even wrote a for loop inside the existing for loop multiple ways. How can I return the objects inside the array? Also, if there is a more server side efficient way to do this that would be appreciated as well.