tsense 0.0.10 → 0.0.12

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/tsense.js CHANGED
@@ -378,7 +378,7 @@ export class TSense {
378
378
  }
379
379
  searchList(options) {
380
380
  return __awaiter(this, void 0, void 0, function* () {
381
- var _a, _b, _c, _d;
381
+ var _a, _b, _c, _d, _e;
382
382
  yield this.ensureSynced();
383
383
  const limit = Math.min((_a = options.limit) !== null && _a !== void 0 ? _a : 20, 100);
384
384
  const field = options.sort.field;
@@ -403,16 +403,16 @@ export class TSense {
403
403
  });
404
404
  const hits = (_d = res.hits) !== null && _d !== void 0 ? _d : [];
405
405
  const data = [];
406
- const lastHit = hits[hits.length - 1].document;
407
- const nextCursor = String(lastHit[field]);
406
+ const lastHit = (_e = hits[hits.length - 1]) === null || _e === void 0 ? void 0 : _e.document;
407
+ const nextCursor = lastHit ? String(lastHit[field]) : null;
408
408
  for (const hit of hits) {
409
409
  const doc = this.deserializeDoc(hit.document);
410
410
  data.push(doc);
411
411
  }
412
412
  if (data.length < limit) {
413
- return { data, nextCursor: null };
413
+ return { data, nextCursor: null, total: res.found };
414
414
  }
415
- return { data, nextCursor };
415
+ return { data, nextCursor, total: res.found };
416
416
  });
417
417
  }
418
418
  upsert(docs) {
package/dist/types.d.ts CHANGED
@@ -114,5 +114,6 @@ export type SearchListOptions<T> = {
114
114
  export type SearchListResult<T> = {
115
115
  data: T[];
116
116
  nextCursor: string | null;
117
+ total: number;
117
118
  };
118
119
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tsense",
3
- "version": "0.0.10",
3
+ "version": "0.0.12",
4
4
  "private": false,
5
5
  "description": "Opinionated, fully typed typesense client",
6
6
  "keywords": [