Sort numerically (0, 1, 2, 3, 4...) instead of (0, 10, 100, 1001, 1002, 1003)

Hello Moralis Mages!

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 think that if those token ids will be converted to numbers then the sort will work as you want.

That makes sense. Is there a way to convert my tokenId column into number format in the Moralis db?

I don’t know of such a way, maybe you can convert it to int in a query that uses pipeline

1 Like