pangea-server 1.0.50 → 1.0.52

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.
@@ -9,7 +9,7 @@ type IncludeItem = {
9
9
  active?: boolean;
10
10
  include?: IncludeItem[];
11
11
  };
12
- type Filters<BM extends BaseModel> = ModelId | Where<BM>;
12
+ type Filters<BM extends BaseModel> = ModelId | Where<BM> | undefined;
13
13
  type Group = string[];
14
14
  type Order = Record<string, 'asc' | 'desc'>;
15
15
  type FindOneOptions = {
@@ -39,9 +39,9 @@ export declare class Db {
39
39
  constructor(tx: Tx);
40
40
  findOneOrNull<BM extends BaseModel>(model: BaseModelCtor<BM>, filters: Filters<BM>, options?: FindOneOptions): Promise<BM | null>;
41
41
  findOne<BM extends BaseModel>(model: BaseModelCtor<BM>, filters: Filters<BM>, options?: FindOneOptions): Promise<BM>;
42
- findManyInstances<BM extends BaseModel>(model: BaseModelCtor<BM>, options?: FindManyPagedOptions<BM>): Promise<BM[]>;
42
+ findMany<BM extends BaseModel>(model: BaseModelCtor<BM>, options?: FindManyPagedOptions<BM>): Promise<BM[]>;
43
43
  count<BM extends BaseModel>(model: BaseModelCtor<BM>, options?: FindManyOptions<BM>): Promise<number>;
44
- findMany<BM extends BaseModel>(model: BaseModelCtor<BM>, options?: FindManyPagedOptions<BM>): Promise<{
44
+ findManyWithCount<BM extends BaseModel>(model: BaseModelCtor<BM>, options?: FindManyPagedOptions<BM>): Promise<{
45
45
  instances: BM[];
46
46
  totalCount: number;
47
47
  }>;
@@ -26,7 +26,7 @@ class Db {
26
26
  }
27
27
  return scopedModel.findOne({
28
28
  ...baseOptions,
29
- ...getIncludeAndWhere(model, include, undefined, filters),
29
+ ...getIncludeAndWhere(model, include, { withoutAttributes: !!attributes }, filters),
30
30
  order: getFinalOrder(order),
31
31
  });
32
32
  }
@@ -36,7 +36,7 @@ class Db {
36
36
  helpers_1.AppError.ThrowEntityNotFound();
37
37
  return instance;
38
38
  }
39
- async findManyInstances(model, options = {}) {
39
+ async findMany(model, options = {}) {
40
40
  const baseOptions = this.__getFindManyBaseOptions(model, options);
41
41
  const { page, pageSize } = options;
42
42
  if (page && pageSize) {
@@ -57,16 +57,13 @@ class Db {
57
57
  const baseOptions = this.__getFindManyBaseOptions(model, options);
58
58
  return model.count({ ...baseOptions, col: 'id', distinct: true });
59
59
  }
60
- async findMany(model, options = {}) {
60
+ async findManyWithCount(model, options = {}) {
61
61
  const { page, pageSize } = options;
62
62
  if (page && pageSize) {
63
- const [instances, totalCount] = await Promise.all([
64
- this.findManyInstances(model, options),
65
- this.count(model, options),
66
- ]);
63
+ const [instances, totalCount] = await Promise.all([this.findMany(model, options), this.count(model, options)]);
67
64
  return { instances, totalCount };
68
65
  }
69
- const instances = await this.findManyInstances(model, options);
66
+ const instances = await this.findMany(model, options);
70
67
  return { instances, totalCount: instances.length };
71
68
  }
72
69
  __getFindManyBaseOptions(model, options = {}) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pangea-server",
3
3
  "description": "",
4
- "version": "1.0.50",
4
+ "version": "1.0.52",
5
5
  "files": [
6
6
  "dist"
7
7
  ],