@aeriajs/core 0.0.168 → 0.0.169

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.
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.makePagination = void 0;
4
+ const count_js_1 = require("../functions/count.js");
4
5
  const common_1 = require("@aeriajs/common");
5
6
  const makePagination = async (payload, documents, context) => {
6
7
  const { offset = 0, limit = context.config.defaultPaginationLimit, } = payload;
@@ -8,7 +9,9 @@ const makePagination = async (payload, documents, context) => {
8
9
  ? (0, common_1.throwIfError)(await context.collection.functions.count({
9
10
  filters: payload.filters,
10
11
  }))
11
- : await context.collection.model.countDocuments(payload.filters);
12
+ : (0, common_1.throwIfError)(await (0, count_js_1.count)({
13
+ filters: payload.filters,
14
+ }, context));
12
15
  return {
13
16
  recordsCount: documents.length,
14
17
  recordsTotal,
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
+ import { count } from "../functions/count.mjs";
2
3
  import { throwIfError } from "@aeriajs/common";
3
4
  export const makePagination = async (payload, documents, context) => {
4
5
  const {
@@ -7,7 +8,9 @@ export const makePagination = async (payload, documents, context) => {
7
8
  } = payload;
8
9
  const recordsTotal = typeof context.collection.functions.count === "function" ? throwIfError(await context.collection.functions.count({
9
10
  filters: payload.filters
10
- })) : await context.collection.model.countDocuments(payload.filters);
11
+ })) : throwIfError(await count({
12
+ filters: payload.filters
13
+ }, context));
11
14
  return {
12
15
  recordsCount: documents.length,
13
16
  recordsTotal,
@@ -3,4 +3,8 @@ import { Result } from '@aeriajs/types';
3
3
  export type CountOptions = {
4
4
  bypassSecurity?: boolean;
5
5
  };
6
- export declare const count: <TContext extends Context>(payload: CountPayload<SchemaWithId<TContext["description"]>>, context: TContext extends Context ? TContext : never, options?: CountOptions) => Promise<Result.Either<any, any>>;
6
+ export declare const count: <TContext extends Context>(payload: CountPayload<SchemaWithId<TContext["description"]>>, context: TContext extends Context ? TContext : never, options?: CountOptions) => Promise<Result.Error<any> | {
7
+ readonly _tag: "Result";
8
+ readonly error: undefined;
9
+ readonly result: any;
10
+ }>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aeriajs/core",
3
- "version": "0.0.168",
3
+ "version": "0.0.169",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "aeriaMain": "tests/fixtures/aeriaMain.js",
@@ -42,13 +42,13 @@
42
42
  "mongodb-memory-server": "^9.2.0"
43
43
  },
44
44
  "peerDependencies": {
45
- "@aeriajs/builtins": "^0.0.168",
46
- "@aeriajs/common": "^0.0.103",
47
- "@aeriajs/entrypoint": "^0.0.105",
48
- "@aeriajs/http": "^0.0.116",
49
- "@aeriajs/security": "^0.0.168",
45
+ "@aeriajs/builtins": "^0.0.169",
46
+ "@aeriajs/common": "^0.0.104",
47
+ "@aeriajs/entrypoint": "^0.0.106",
48
+ "@aeriajs/http": "^0.0.117",
49
+ "@aeriajs/security": "^0.0.169",
50
50
  "@aeriajs/types": "^0.0.87",
51
- "@aeriajs/validation": "^0.0.106"
51
+ "@aeriajs/validation": "^0.0.107"
52
52
  },
53
53
  "dependencies": {
54
54
  "mongodb": "^6.5.0",