Sync events on local dev chain

Hey so you advised me to use beforeSave but I can’t change how the event will be saved right ?

What you mean that you can’t change?

As of now events are saved depending on the abi I would like to change how they are saved, edit the scheme in some sort of way.

Because right now all I can do is to create another Table which will be fed by the beforeSave trigger.

You can change the fields names in the original abi that you use too, you should be able to make changes in event schema like adding a new column in beforeSave too

My contracts are already deployed so i can’t change the abi. But is it possible to edit the field names also?
Could you show me how ?
Btw thank you very much for your help, what a team !

It doesn’t matter what you have as field name in your contract, when you add an event for sync you can change the name field for a column in something else directly in the abi that you paste there.

It doesn’t matter what you have as field name in your contract, when you add an event for sync you can change the name field for a column in something else directly in the abi that you paste there.

Nice I didn’t know that and so how do I add new fields in beforeSave trigger, do you have examples?

I can give you an example maybe in an hour.

Ok I’ll wait thank you very much !

https://docs.moralis.io/moralis-server/cloud-code/triggers#modifying-objects-on-save

Moralis.Cloud.beforeSave("Review", (request) => {
  const comment = request.object.get("comment");
  if (comment.length > 140) {
    // Truncate and add a ...
    request.object.set("comment", comment.substring(0, 137) + "...");
    request.object.set("new_field", comment.substring(0, 137) + "...");
  }
});
2 Likes

Thank you very much for your help !!

1 Like