@abejarano/ts-mongodb-criteria 1.5.0 → 1.5.1

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.
@@ -21,7 +21,7 @@ class MongoRepository {
21
21
  }
22
22
  /** Upserts an aggregate by delegating to persist with its id. */
23
23
  async upsert(entity) {
24
- return this.persist(entity.getId(), entity);
24
+ await this.persist(entity.getId(), entity);
25
25
  }
26
26
  /** Lists entities by criteria and returns a paginated response. */
27
27
  async list(criteria, fieldsToExclude = []) {
@@ -35,10 +35,9 @@ class MongoRepository {
35
35
  }
36
36
  async updateOne(filter, update) {
37
37
  const collection = await this.collection();
38
- const result = await collection.updateOne(filter, update, {
38
+ await collection.updateOne(filter, update, {
39
39
  upsert: true,
40
40
  });
41
- return result.upsertedId;
42
41
  }
43
42
  async persist(id, aggregateRoot) {
44
43
  let primitives;
@@ -48,7 +47,7 @@ class MongoRepository {
48
47
  else {
49
48
  primitives = aggregateRoot.toPrimitives();
50
49
  }
51
- return await this.updateOne({ _id: new mongodb_1.ObjectId(id) }, {
50
+ await this.updateOne({ _id: new mongodb_1.ObjectId(id) }, {
52
51
  $set: {
53
52
  ...primitives,
54
53
  id: id,
@@ -18,7 +18,7 @@ export class MongoRepository {
18
18
  }
19
19
  /** Upserts an aggregate by delegating to persist with its id. */
20
20
  async upsert(entity) {
21
- return this.persist(entity.getId(), entity);
21
+ await this.persist(entity.getId(), entity);
22
22
  }
23
23
  /** Lists entities by criteria and returns a paginated response. */
24
24
  async list(criteria, fieldsToExclude = []) {
@@ -32,10 +32,9 @@ export class MongoRepository {
32
32
  }
33
33
  async updateOne(filter, update) {
34
34
  const collection = await this.collection();
35
- const result = await collection.updateOne(filter, update, {
35
+ await collection.updateOne(filter, update, {
36
36
  upsert: true,
37
37
  });
38
- return result.upsertedId;
39
38
  }
40
39
  async persist(id, aggregateRoot) {
41
40
  let primitives;
@@ -45,7 +44,7 @@ export class MongoRepository {
45
44
  else {
46
45
  primitives = aggregateRoot.toPrimitives();
47
46
  }
48
- return await this.updateOne({ _id: new ObjectId(id) }, {
47
+ await this.updateOne({ _id: new ObjectId(id) }, {
49
48
  $set: {
50
49
  ...primitives,
51
50
  id: id,
@@ -1,8 +1,7 @@
1
- import { ObjectId } from "mongodb";
2
1
  import { Criteria, Paginate } from "../criteria";
3
2
  import { AggregateRoot } from "../AggregateRoot";
4
3
  export interface IRepository<T extends AggregateRoot> {
5
4
  one(filter: object): Promise<T | null>;
6
5
  list<D>(criteria: Criteria, fieldsToExclude?: string[]): Promise<Paginate<D>>;
7
- upsert(entity: T): Promise<ObjectId | null>;
6
+ upsert(entity: T): Promise<void>;
8
7
  }
@@ -1,6 +1,6 @@
1
1
  import { Criteria, Paginate } from "../criteria";
2
2
  import { AggregateRoot, AggregateRootClass } from "../AggregateRoot";
3
- import { Collection, ObjectId, UpdateFilter } from "mongodb";
3
+ import { Collection, UpdateFilter } from "mongodb";
4
4
  export declare abstract class MongoRepository<T extends AggregateRoot> {
5
5
  private readonly aggregateRootClass;
6
6
  private criteriaConverter;
@@ -11,11 +11,11 @@ export declare abstract class MongoRepository<T extends AggregateRoot> {
11
11
  /** Finds a single entity and hydrates it via the aggregate's fromPrimitives. */
12
12
  one(filter: object): Promise<T | null>;
13
13
  /** Upserts an aggregate by delegating to persist with its id. */
14
- upsert(entity: T): Promise<ObjectId | null>;
14
+ upsert(entity: T): Promise<void>;
15
15
  /** Lists entities by criteria and returns a paginated response. */
16
16
  list<D>(criteria: Criteria, fieldsToExclude?: string[]): Promise<Paginate<D>>;
17
17
  protected collection<T extends Document>(): Promise<Collection<T>>;
18
- protected updateOne(filter: object, update: Document[] | UpdateFilter<any>): Promise<ObjectId | null>;
18
+ protected updateOne(filter: object, update: Document[] | UpdateFilter<any>): Promise<void>;
19
19
  private persist;
20
20
  private searchByCriteria;
21
21
  private paginate;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@abejarano/ts-mongodb-criteria",
3
3
  "author": "angel bejarano / angel.bejarano@jaspesoft.com",
4
- "version": "1.5.0",
4
+ "version": "1.5.1",
5
5
  "description": "Patrón Criteria para consultas MongoDB en TypeScript",
6
6
  "main": "dist/cjs/index.js",
7
7
  "module": "dist/esm/index.js",