c2-mongoose 2.1.0 → 2.1.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.
@@ -4,7 +4,8 @@ import SearchFlow from "./SearchFlow";
4
4
  declare class CrudFlow<D> {
5
5
  private repository;
6
6
  private search;
7
- constructor(repository: mongoose.Model<any>, search: SearchFlow);
7
+ constructor(repository: mongoose.Model<any>, search?: SearchFlow);
8
+ prepareSearch(search: SearchFlow): void;
8
9
  create(data: any, session?: any): Promise<any[]>;
9
10
  delete(id: string, session?: any): Promise<void>;
10
11
  update(id: string, data: D, session?: any): Promise<D>;
@@ -41,6 +41,9 @@ var CrudFlow = /** @class */ (function () {
41
41
  this.repository = repository;
42
42
  this.search = search;
43
43
  }
44
+ CrudFlow.prototype.prepareSearch = function (search) {
45
+ this.search = search;
46
+ };
44
47
  CrudFlow.prototype.create = function (data, session) {
45
48
  if (session === void 0) { session = undefined; }
46
49
  return __awaiter(this, void 0, void 0, function () {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "c2-mongoose",
3
- "version": "2.1.0",
3
+ "version": "2.1.1",
4
4
  "description": "Lib to make any search in database mongoose and use as basic crud",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -7,10 +7,14 @@ class CrudFlow<D> {
7
7
  private repository: mongoose.Model<any>
8
8
  private search: any
9
9
 
10
- constructor(repository: mongoose.Model<any>, search: SearchFlow) {
10
+ constructor(repository: mongoose.Model<any>, search?: SearchFlow) {
11
11
  this.repository = repository
12
12
  this.search = search
13
13
  }
14
+
15
+ public prepareSearch(search: SearchFlow) {
16
+ this.search = search
17
+ }
14
18
 
15
19
  public async create(data: any, session: any = undefined) {
16
20
  return await this.repository.create([data], { session })