[SOLVED] Moralis Database Problem

Hi, I encountered a problem after creating new Moralis server on Goerli. Previously I’ve been using Rinkeby and everything was working smoothly.

I hava a pretty simple cloud function:

Moralis.Cloud.define('depositsData', async request => {
  const { token } = request.params

  if (token !== 'Banana' && token !== 'Zug') {
    return null
  }

  const query = new Moralis.Query('Deposit')

  const pipeline = [
    {
      group: {
        objectId: '$token',
        depositedAllTime: {
          $sum: '$amount',
        },
      },
    },
  ]

  const results = await query.aggregate(pipeline, { useMasterKey: true })

  const result = results.find(el => el.objectId === token)

  return result || { depositedAllTime: 0 }
})

I also have these rows in my database:

The problem is that depositedAllTime is always 0, like so:
image

It worked perfectly before, but suddenly stopped after creating new instance on Goerli. I don’t think that it’s related to testnet change, but don’t really have an idea what could be the cause.

Does anyone have any idea what could I do?

Maybe because that amount is string?

Oh I didn’t catch that, you’re probably right. Is there any way to change column type in Moralis Dashboard? I can’t find an option like that.

I don’t know of a way to change the type, you could create a new column

Aight I did removed this column and add new one with same name and different type and it works now, thanks.

1 Like