Event sync data types string instead of number on collection columns

Hi everyone.
I have an event sync on the Moralis configuration panel with the following elements:

Topic is:

MarketItemUnlisted (address, uint, uint256 , address, uint256)

ABI is


{
  "anonymous": false,
  "inputs": [
    {
      "indexed": true,
      "internalType": "address",
      "name": "nftContract",
      "type": "address"
    },
    {
      "indexed": true,
      "internalType": "uint256",
      "name": "itemId",
      "type": "uint256"
    },
    {
      "indexed": true,
      "internalType": "uint256",
      "name": "tokenId",
      "type": "uint256"
    },
    {
      "indexed": false,
      "internalType": "address",
      "name": "owner",
      "type": "address"
    },
    {
      "indexed": false,
      "internalType": "uint256",
      "name": "blockNumber",
      "type": "uint256"
    }
  ],
  "name": "MarketItemUnlisted",
  "type": "event"
}

I canโ€™t figure out why when this is saved as a collection in the Moralis DB the types of tokenId, itemId and blockNumber for example are automatically stored on columns with String type instead of Number.

Iโ€™d prefer Number type for checks, data ordering, and in general just for integrity with the same columns types that I defined on the other classes of the database, how can I do to fix this?

Thank you

Hi,

You can use a hook like beforeSave of afterSave for small numbers. In general, you can not add any uint256 in a column in database because that number is bigger than what a column can handle in the database.

Thank you for your reply.

What flow would you suggest using beforeSave or afterSave to solve it?

What uintXY is the max that would be automatically saved as Number on the db column type? Thank you

128 bits can be used with decimal type, but I donโ€™t know how you can set the type of a column to decimal now, uint32 should work without problems

Thanks. With beforeSave you mean that I can handle it casting before itโ€™s saved in the Database?

something like


Moralis.Cloud.beforeSave("MarketItemsUnlisted", (request) => {

const tokenId = Number (request.object.get("tokenId"));

request.object.set("tokenId", tokenId);

});

no really that, I mean that you can create another column that is of type integer, and convert that value to an integer and save it in that new created column.

Ok clear, but would it be possible to create a new column on a event sync collection? In the code example posted above maybe changing the column name like

request.object.set("tokenIdNumber", tokenId);

Would do this?

Thanks

you can do that in the dashboard interface for that server, you add a new column to that table as you would be adding a new column to any table from that interface.

Clear thanks for your help