@objectstack/objectql 10.2.0 → 10.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -3999,16 +3999,37 @@ var _ObjectStackProtocolImplementation = class _ObjectStackProtocolImplementatio
3999
3999
  return {
4000
4000
  object: request.object,
4001
4001
  records: limited,
4002
- total: limited.length,
4003
- hasMore: false
4002
+ total: records2.length,
4003
+ hasMore: limited.length < records2.length
4004
4004
  };
4005
4005
  }
4006
4006
  const records = await this.engine.find(request.object, options);
4007
+ const pageLimit = typeof options.limit === "number" && options.limit > 0 ? options.limit : void 0;
4008
+ const pageOffset = typeof options.offset === "number" && options.offset > 0 ? options.offset : 0;
4009
+ let total = records.length;
4010
+ let hasMore = false;
4011
+ if (pageLimit !== void 0) {
4012
+ const countable = options.search == null && options.distinct == null;
4013
+ if (countable) {
4014
+ try {
4015
+ total = await this.engine.count(request.object, {
4016
+ where: options.where,
4017
+ context: options.context
4018
+ });
4019
+ } catch {
4020
+ total = pageOffset + records.length;
4021
+ }
4022
+ hasMore = pageOffset + records.length < total;
4023
+ } else {
4024
+ hasMore = records.length === pageLimit;
4025
+ total = pageOffset + records.length + (hasMore ? 1 : 0);
4026
+ }
4027
+ }
4007
4028
  return {
4008
4029
  object: request.object,
4009
4030
  records,
4010
- total: records.length,
4011
- hasMore: false
4031
+ total,
4032
+ hasMore
4012
4033
  };
4013
4034
  }
4014
4035
  async getData(request) {