Adding elements in Moralis object


Im trying to query mongo collection in my cloud function.

const results = await query.find();

And on this results, I need to add few more elements, basis the result I get.

This can be done easliy in javascript, but when the same code runs on cloudFunction, it’s not working.

let newVar = results[0];
newVar["key"] = 'value';

This add the new key in my results object in javascript code, but shows no result in Moralis cloud Function.

Can someone please help me with the resolution.

you can read in the documentation here:

you will have to use .set and .save

1 Like

It worked thanks!

newVar.set("key", "value");