c2-mongoose 2.1.358 → 2.1.360

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.
@@ -82,14 +82,14 @@ var C2Flow = /** @class */ (function () {
82
82
  var dataAfter, log;
83
83
  return __generator(this, function (_a) {
84
84
  switch (_a.label) {
85
- case 0: return [4 /*yield*/, this.repository.create(data, { session: options.session })];
85
+ case 0: return [4 /*yield*/, this.repository.create(data, { session: options.session, ordered: true })];
86
86
  case 1:
87
87
  dataAfter = _a.sent();
88
88
  if (options.logger === false || (0, Utils_1.isEmpty)(dataAfter)) {
89
89
  return [2 /*return*/, dataAfter];
90
90
  }
91
91
  log = BuildLogFlowItem_1.default.build(options, dataAfter[0]._doc, Logger_1.TypeOfOperation.CREATE, this.repository);
92
- return [4 /*yield*/, global.LoggerRepository.create([log], { session: options.session })];
92
+ return [4 /*yield*/, global.LoggerRepository.create([log], { session: options.session, ordered: true })];
93
93
  case 2:
94
94
  _a.sent();
95
95
  return [2 /*return*/, dataAfter];
@@ -6,19 +6,7 @@ declare class CrudFlow<D> {
6
6
  private search;
7
7
  constructor(repository: mongoose.Model<any>, search?: SearchFlow);
8
8
  prepareSearch(search: SearchFlow): void;
9
- create(data: any, session?: any): Promise<((mongoose.Document<unknown, any, Omit<any, "_id"> & {
10
- _id: mongoose.Types.ObjectId;
11
- }> & Omit<any, "_id"> & {
12
- _id: mongoose.Types.ObjectId;
13
- } & {
14
- _id: mongoose.Types.ObjectId;
15
- }) | (mongoose.Document<unknown, any, Omit<any, "_id"> & Required<{
16
- _id: unknown;
17
- }>> & Omit<any, "_id"> & Required<{
18
- _id: unknown;
19
- }> & {
20
- _id: mongoose.Types.ObjectId;
21
- }))[]>;
9
+ create(data: any, session?: any): Promise<any[]>;
22
10
  delete(id: string, session?: any): Promise<void>;
23
11
  deleteMany(conditions: {}, session?: any): Promise<void>;
24
12
  update(id: string, data: D, session?: any): Promise<D>;
@@ -1,6 +1,14 @@
1
1
  import mongoose from "mongoose";
2
2
  declare class GetFieldDefinitionFlowItem {
3
- execute(modelRoot: mongoose.Model<any, {}, {}, {}, any>, first: string): mongoose.SchemaType<any>;
3
+ execute(modelRoot: mongoose.Model<any, {}, {}, {}, any, any>, first: string): mongoose.SchemaType<any, mongoose.Document<unknown, {}, mongoose.FlatRecord<{
4
+ [x: string]: unknown;
5
+ }>, {}> & mongoose.FlatRecord<{
6
+ [x: string]: unknown;
7
+ }> & Required<{
8
+ _id: unknown;
9
+ }> & {
10
+ __v: number;
11
+ }>;
4
12
  }
5
13
  declare const _default: GetFieldDefinitionFlowItem;
6
14
  export default _default;
@@ -1,6 +1,6 @@
1
1
  import mongoose from "mongoose";
2
2
  declare class GetTypeOfFieldInModelFlowItem {
3
- exec(fieldToGroup: string, modelRoot: mongoose.Model<any, {}, {}, {}, any>): string;
3
+ exec(fieldToGroup: string, modelRoot: mongoose.Model<any, {}, {}, {}, any, any>): string;
4
4
  }
5
5
  declare const _default: GetTypeOfFieldInModelFlowItem;
6
6
  export default _default;
@@ -1,6 +1,14 @@
1
1
  import mongoose from "mongoose";
2
2
  declare class GetFieldDefinitionFlowItem {
3
- execute(modelRoot: mongoose.Model<any, {}, {}, {}, any>, first: string): mongoose.SchemaType<any>;
3
+ execute(modelRoot: mongoose.Model<any, {}, {}, {}, any, any>, first: string): mongoose.SchemaType<any, mongoose.Document<unknown, {}, mongoose.FlatRecord<{
4
+ [x: string]: unknown;
5
+ }>, {}> & mongoose.FlatRecord<{
6
+ [x: string]: unknown;
7
+ }> & Required<{
8
+ _id: unknown;
9
+ }> & {
10
+ __v: number;
11
+ }>;
4
12
  }
5
13
  declare const _default: GetFieldDefinitionFlowItem;
6
14
  export default _default;
@@ -1,6 +1,6 @@
1
1
  import mongoose from "mongoose";
2
2
  declare class GetTypeOfFieldInModelFlowItem {
3
- exec(fieldToGroup: string, modelRoot: mongoose.Model<any, {}, {}, {}, any>): string;
3
+ exec(fieldToGroup: string, modelRoot: mongoose.Model<any, {}, {}, {}, any, any>): string;
4
4
  }
5
5
  declare const _default: GetTypeOfFieldInModelFlowItem;
6
6
  export default _default;
@@ -1,5 +1,5 @@
1
1
  import moment from 'moment';
2
- import mongoose, { Schema, Types } from 'mongoose';
2
+ import mongoose, { Types } from 'mongoose';
3
3
  import SearchFlow from '../flow/SearchFlow';
4
4
  declare enum TypeOfOperation {
5
5
  "CREATE" = "CREATE",
@@ -16,14 +16,39 @@ interface ILogger {
16
16
  filters: any;
17
17
  notes: string;
18
18
  }
19
- declare const LoggerModel: mongoose.Schema<any, mongoose.Model<any, any, any, any, any>, {}, {}, any, {}, "type", {
20
- owner: Schema.Types.ObjectId;
21
- user: Schema.Types.ObjectId;
19
+ declare const LoggerModel: mongoose.Schema<any, mongoose.Model<any, any, any, any, any, any>, {}, {}, {}, {}, {
20
+ timestamps: {
21
+ createdAt: string;
22
+ updatedAt: string;
23
+ };
24
+ }, {} & {
25
+ owner: Types.ObjectId;
26
+ user: Types.ObjectId;
27
+ collectionName: string;
28
+ operation: string;
29
+ data?: any;
30
+ filters?: any;
31
+ notes?: string | null | undefined;
32
+ }, mongoose.Document<unknown, {}, mongoose.FlatRecord<{} & {
33
+ owner: Types.ObjectId;
34
+ user: Types.ObjectId;
35
+ collectionName: string;
36
+ operation: string;
37
+ data?: any;
38
+ filters?: any;
39
+ notes?: string | null | undefined;
40
+ }>, {}> & mongoose.FlatRecord<{} & {
41
+ owner: Types.ObjectId;
42
+ user: Types.ObjectId;
22
43
  collectionName: string;
23
44
  operation: string;
24
45
  data?: any;
25
46
  filters?: any;
26
- notes?: string | undefined;
47
+ notes?: string | null | undefined;
48
+ }> & {
49
+ _id: Types.ObjectId;
50
+ } & {
51
+ __v: number;
27
52
  }>;
28
53
  declare class LoggerSearch extends SearchFlow {
29
54
  model: Partial<ILogger>;
@@ -5,5 +5,5 @@ export declare const isNotEmpty: (obj: any) => boolean;
5
5
  export declare const isEmpty: (obj: any) => boolean;
6
6
  export declare const isIterable: (input: any) => boolean;
7
7
  export declare const isNotIterable: (input: any) => boolean;
8
- export declare const compareAsc: (a: any, b: any) => 1 | 0 | -1;
9
- export declare const compareDesc: (a: any, b: any) => 1 | 0 | -1;
8
+ export declare const compareAsc: (a: any, b: any) => 0 | 1 | -1;
9
+ export declare const compareDesc: (a: any, b: any) => 0 | 1 | -1;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "c2-mongoose",
3
- "version": "2.1.358",
3
+ "version": "2.1.360",
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",
@@ -32,7 +32,7 @@
32
32
  "express-http-context": "^1.2.4",
33
33
  "moment": "^2.29.4",
34
34
  "moment-timezone": "^0.5.43",
35
- "mongoose": "6.4.0"
35
+ "mongoose": "8.16.1"
36
36
  },
37
37
  "devDependencies": {
38
38
  "typescript": "^4.9.5"
@@ -28,14 +28,14 @@ class C2Flow<D> {
28
28
  }
29
29
 
30
30
  async createMany(data: Partial<D>[], options: Partial<Options>): Promise<Partial<D>[]> {
31
- let dataAfter = await this.repository.create(data, { session: options.session })
31
+ let dataAfter = await this.repository.create(data, { session: options.session, ordered: true })
32
32
 
33
33
  if (options.logger === false || isEmpty(dataAfter)) {
34
34
  return dataAfter
35
35
  }
36
36
 
37
37
  let log: Partial<ILogger> = BuildLogFlowItem.build(options, dataAfter[0]._doc, TypeOfOperation.CREATE, this.repository)
38
- await (global as any).LoggerRepository.create([log], { session: options.session })
38
+ await (global as any).LoggerRepository.create([log], { session: options.session, ordered: true })
39
39
 
40
40
  return dataAfter
41
41
  }
@@ -1,7 +1,7 @@
1
1
  import mongoose from "mongoose";
2
2
 
3
3
  class GetFieldDefinitionFlowItem {
4
- execute(modelRoot: mongoose.Model<any, {}, {}, {}, any>, first: string) {
4
+ execute(modelRoot: mongoose.Model<any, {}, {}, {}, any, any>, first: string) {
5
5
  let fieldDefinition = modelRoot.schema.path(first);
6
6
 
7
7
  if (!fieldDefinition && modelRoot.discriminators) {
@@ -1,7 +1,7 @@
1
1
  import mongoose from "mongoose"
2
2
 
3
3
  class GetTypeOfFieldInModelFlowItem {
4
- exec(fieldToGroup: string, modelRoot: mongoose.Model<any, {}, {}, {}, any>): string {
4
+ exec(fieldToGroup: string, modelRoot: mongoose.Model<any, {}, {}, {}, any, any>): string {
5
5
  let fieldDefinition = modelRoot.schema.path(fieldToGroup)
6
6
  return fieldDefinition.instance
7
7
  }
@@ -1,7 +1,7 @@
1
1
  import mongoose from "mongoose";
2
2
 
3
3
  class GetFieldDefinitionFlowItem {
4
- execute(modelRoot: mongoose.Model<any, {}, {}, {}, any>, first: string) {
4
+ execute(modelRoot: mongoose.Model<any, {}, {}, {}, any, any>, first: string) {
5
5
  let fieldDefinition = modelRoot.schema.path(first);
6
6
 
7
7
  if (!fieldDefinition && modelRoot.discriminators) {
@@ -1,7 +1,7 @@
1
1
  import mongoose from "mongoose"
2
2
 
3
3
  class GetTypeOfFieldInModelFlowItem {
4
- exec(fieldToGroup: string, modelRoot: mongoose.Model<any, {}, {}, {}, any>): string {
4
+ exec(fieldToGroup: string, modelRoot: mongoose.Model<any, {}, {}, {}, any, any>): string {
5
5
  let fieldDefinition = modelRoot.schema.path(fieldToGroup)
6
6
  return fieldDefinition.instance
7
7
  }