Hi, I have created one sync that watches for my custom mint event.
I have a beforeSave that watches for the new entry in the associated db, andā¦ I get some weird results:
1- The log is really strange, the before save is called 3 times !?!
The log is bottom to top
** And another call with confirmed false !?! **
** and no ābeforeSave calledā, which is impossible !!! **
- 2022-07-19T18:45:28.095Z - confirmed: false
** What the ??? a second call with true ?! **
7. 2022-07-19T18:53:47.581Z - confirmed: true
8. 2022-07-19T18:53:47.580Z - beforeSave called**Second call: normal, the transaction is confirmed **
14. 2022-07-19T18:53:47.295Z - confirmed: true
15. 2022-07-19T18:53:47.294Z - beforeSave calledFirst This is normal
16. 2022-07-19T18:45:28.095Z - confirmed: false
17. 2022-07-19T18:45:28.095Z - beforeSave called
2- it is supposed to modify an object in db, but it does not
const medalId = request.object.get('medalId')
const tokenId = request.object.get('tokenId')
const to = request.object.get('to')
logger.info("medalid " + medalId)
logger.info("tokenId " + tokenId)
logger.info("to " + to)
// I checked the log, the values are coherent
// We look for medaille
const Medaille = Moralis.Object.extend("Medaille")
let aquery = new Moralis.Query(Medaille);
aquery.equalTo("objectId", medalId)
const _result = await aquery.find({ useMasterKey: true })
logger.info("length " + _result.length)
// 1 is found, no issue !
const medaille = _result[0]
// we update the medal
medaille.set("tokenId", tokenId)
medaille.set("minted", true)
medaille.set("to", to)
try {
medaille.fetch({ useMasterKey: true })
But the medal db is not updated !
Is there something obvious I missed !?
Cheers