This is for the Moralis API to make Ethereum apps. I am using getAllTokenIds() to pull data for an NFT collection, and storing the data in Moralis database.
using this line: query.ascending(“tokenId”);
my results are coming in with the token ids (0, 1, 10, 100, 1000, 10000, 10001, 10002, 10003 …) how do I make it so my order for token Ids is (0, 1, 2, 3, 4, 5 …)?
I have tried to look up ways to convert my token Ids columns into number format, but I am not sure if there is a way to do it in the Moralis database.
GM there,
usually the
tokenId
returned will be string, so it will order it like a stringSo one solutions would be after you pushed the result to Moralis DB, run
beforeSave
orafterSave
to make a new column that save the integer version of thetokenId
sAlternatively, convert those
tokenId
s to integer first before pushing then to Moralis DBLet me know if you found something else
Cheers~