When Iām trying to fetch events from one table, process them and save them to another table - it fails if the first table contained NumberDecimals (pretty much all tables).
Example simplified code:
const addNFTEvent = Moralis.Object.extend("AddNFT");
const addNFTquery = new Moralis.Query(addNFTEvent);
const addNFT = await addNFTquery.first();
addNFT.set("action", "changeOwner");
let obj = Moralis.Object.extend("NFT");
let NFTobj = new obj();
await NFTobj.save(addNFT.attributes, { useMasterKey: true });
The error that is given looks like this:
2022-06-11T11:02:23.365Z - TypeError: string.trim is not a function
at Function.Decimal128.fromString (/moralis-server/node_modules/mongodb/node_modules/bson/lib/bson/decimal128.js:238:19)
at Object.JSONToDatabase (/moralis-server/lib/Adapters/Storage/Mongo/MongoTransform.js:1831:31)
at transformTopLevelAtom (/moralis-server/lib/Adapters/Storage/Mongo/MongoTransform.js:835:35)
at parseObjectKeyValueToMongoObjectKeyValue (/moralis-server/lib/Adapters/Storage/Mongo/MongoTransform.js:608:15)
at parseObjectToMongoObjectForCreate (/moralis-server/lib/Adapters/Storage/Mongo/MongoTransform.js:656:9)
at MongoStorageAdapter.createObject (/moralis-server/lib/Adapters/Storage/Mongo/MongoStorageAdapter.js:442:79)
at /moralis-server/lib/Controllers/DatabaseController.js:818:29
at runMicrotasks (<anonymous>)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
If I convert the NumberDecimal type to string and pass it as a string - it says:
expected NumberDecimal but got String
Everything worked before Nitro update (cause there were no NumberDecimal types by default in tables).
If I strip out all NumberDecimal fields from the attributes object and then save - it works, but NumberDecimal fields are left āundefinedā.
P.S. Also creating a column of āNumberDecimalā type fails on the UI:
This shows āinvalid field type: NumberDecimalā error in the corner and doesnāt create a column.