Hi, I use the cloud code to get data but when I call from out server, It too slow. This is my code
Moralis.Cloud.define("getSaleHeroes", async (request) => {
const query = new Moralis.Query("HeroesForSale");
query.equalTo("delist", false);
if (request.params.page && request.params.pageSize) {
let pageSize = request.params.pageSize;
let page = request.params.page;
let toSkip = (page-1)*pageSize;
query.skip(toSkip);
query.limit(pageSize);
}
if (request.params.filters) {
const logger = Moralis.Cloud.getLogger();
logger.info(request.params.filters);
const Heroes = Moralis.Object.extend("Heroes");
const innerQuery = new Moralis.Query(Heroes);
if (request.params.filters.rarities) {
innerQuery.containedIn('rarity', request.params.filters.rarities);
}
if (request.params.filters.levels) {
innerQuery.containedIn('level', request.params.filters.levels);
}
if (request.params.filters.types) {
innerQuery.containedIn('type', request.params.filters.types);
}
query.matchesQuery("heroRelation", innerQuery);
}
query.descending("createdAt");
query.select("heroId_", "price_", "owner_", "heroRelation.type", "heroRelation.name", "heroRelation.rarity", "heroRelation.level", "heroRelation.experience", "heroRelation.lastBattleTime");
query.withCount();
const queryResults = await query.find({useMasterKey: true});
const results = [];
const dataResults = queryResults.results;
for (let i = 0; i < dataResults.length; ++i) {
results.push({
"heroId": dataResults[i].attributes.heroId_,
"price": dataResults[i].attributes.price_,
"owner": dataResults[i].attributes.owner_,
"type": dataResults[i].attributes.heroRelation.attributes.type,
"name": dataResults[i].attributes.heroRelation.attributes.name,
"rarity": dataResults[i].attributes.heroRelation.attributes.rarity,
"level": dataResults[i].attributes.heroRelation.attributes.level,
"experience": dataResults[i].attributes.heroRelation.attributes.experience,
"lastBattleTime": dataResults[i].attributes.heroRelation.attributes.lastBattleTime,
});
}
return {'data': results, 'totalCount': queryResults.count};
});```