Is there a way to return all rows of a table instead of only 100? using masterkey or something?
I would like to return all because I need to add a property in each object and then order by this property to send to the frontend sorted.
example:
const final = await robotsQuery.withCount().find();
for (let index = 0; index < final.results.length; index++) {
const mktrobot = await new Moralis.Query("RobotsOnSale")
.descending("block_timestamp")
.equalTo("tokenId", final.results[index].attributes.TokenId.toString())
.first();
if (!mktrobot) continue;
const result = Moralis.Cloud.units({
method: "fromWei",
value: mktrobot.attributes.startingPrice,
});
final.results[index].price = +result;
}
const robots = await GetRobots(final.results);
const sortedRobots = robots.sort((a, b) => a.price - b.price);
if (
sortedRobots.slice(pagesToSkip, pagesToSkip + robotsPerPage).length == 0
) {
page = 1;
pagesToSkip = 0;
}
note that “robotsQuery” is a different query than “RobotsOnSale”. Doing it through aggregator is too painful so I think this way was much easier…