Hi @cryptokid,
The before save trigger that I defined in the cloud function is triggered. collection creation is successfull but nfts.save() in frontend is happening without request.object.set. In other words, the save process working before my operations in the trigger function are finished. I can see this in the logs. What is the reason?
Moralis.Cloud.beforeSave("Nfts", function(request,response) {
const userCollection = request.object.get("collection");
logger.info(JSON.stringify(request.object));
if (userCollection) {
logger.info("success");
} else {
logger.info("fail");
const UserCollection = Moralis.Object.extend("UserCollections");
const collection = new UserCollection();
collection.set("userId", request.object.get("userId"));
collection.set("title", "UntitledCollection");
collection.set("description", "My first collection");
collection.save(null, { useMasterKey: true }).then((usercollection) => {
logger.info(JSON.stringify(usercollection));
request.object.set('collection',usercollection);
return request.object;
logger.info(JSON.stringify(request.object));
});
}
});