Retrieve object from database and update

Hello,

In documentation, example shows that - to update object, we need to store it in variable after save().

But I need to query object from database and save. like this:
(Need this in cloud functions)

    const Items = Parse.Object.extend("Items");
    const query = new Parse.Query(Items);
    query.equalTo("tokenAddress", "0x0000000000000000000000000000000000000003");
    const result = await query.first();
    result.set("status", 100);
    result.save();

I know, that first() function will not work, but what should I use instead? Can’t get it working…

you can try query.first({useMasterKey:true})
and you can also use logger.info(JSON.stringify(result)); to see what you got there.

1 Like