diff --git a/packages/node-core/src/indexer/store.service.ts b/packages/node-core/src/indexer/store.service.ts index a9b420a4d9..8935c70f69 100644 --- a/packages/node-core/src/indexer/store.service.ts +++ b/packages/node-core/src/indexer/store.service.ts @@ -694,10 +694,15 @@ group by upperFirst(camelCase(indexField.entityName)) === entity && camelCase(indexField.fieldName) === field ) > -1; assert(indexed, `to query by field ${String(field)}, an index must be created on model ${entity}`); + if (options?.limit && this.config.queryLimit < options?.limit) { + logger.warn( + `store getByField for entity ${entity} with ${options.limit} records exceeds config limit ${this.config.queryLimit}. Will use ${this.config.queryLimit} as the limit.` + ); + } const records = await model.findAll({ where: {[field]: value}, transaction: this.tx, - limit: options?.limit ?? this.config.queryLimit, + limit: options?.limit ? Math.min(options?.limit, this.config.queryLimit) : this.config.queryLimit, offset: options?.offset, }); return records.map((record) => record.toJSON() as T);