@kipicore/dbcore 1.1.158 → 1.1.160
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.
- package/dist/models/mongodb/competitionModel.js +3 -3
- package/dist/services/Concrete/mongooseCommonService.d.ts +5 -0
- package/dist/services/Concrete/mongooseCommonService.js +7 -0
- package/dist/services/Concrete/sequelizeCommonService.d.ts +1 -0
- package/dist/services/Concrete/sequelizeCommonService.js +8 -0
- package/dist/services/Contracts/IMongooseCommonService.d.ts +5 -0
- package/dist/services/Contracts/ISequelizeCommonService.d.ts +1 -0
- package/package.json +1 -1
|
@@ -101,7 +101,7 @@ const CompetitionSchema = new mongoose_1.Schema({
|
|
|
101
101
|
},
|
|
102
102
|
rules: {
|
|
103
103
|
type: String,
|
|
104
|
-
required:
|
|
104
|
+
required: false,
|
|
105
105
|
},
|
|
106
106
|
maxGroupSize: {
|
|
107
107
|
type: Number,
|
|
@@ -142,7 +142,7 @@ const CompetitionSchema = new mongoose_1.Schema({
|
|
|
142
142
|
},
|
|
143
143
|
isNeedApproval: {
|
|
144
144
|
type: Boolean,
|
|
145
|
-
required:
|
|
145
|
+
required: false,
|
|
146
146
|
},
|
|
147
147
|
subCategory: {
|
|
148
148
|
type: String,
|
|
@@ -150,7 +150,7 @@ const CompetitionSchema = new mongoose_1.Schema({
|
|
|
150
150
|
},
|
|
151
151
|
academicCalendarId: {
|
|
152
152
|
type: String,
|
|
153
|
-
required:
|
|
153
|
+
required: false,
|
|
154
154
|
},
|
|
155
155
|
instituteId: {
|
|
156
156
|
type: String,
|
|
@@ -30,6 +30,11 @@ export declare class MongooseCommonService<T extends Document> implements IMongo
|
|
|
30
30
|
userId?: string;
|
|
31
31
|
session?: ClientSession;
|
|
32
32
|
}): Promise<UpdateWriteOpResult | null>;
|
|
33
|
+
hardDelete(filter: FilterQuery<T>, options?: MongooseUpdateQueryOptions<T> & {
|
|
34
|
+
session?: ClientSession;
|
|
35
|
+
}): Promise<{
|
|
36
|
+
deletedCount?: number;
|
|
37
|
+
}>;
|
|
33
38
|
aggregate(pipeline: PipelineStage[]): Promise<{
|
|
34
39
|
[key: string]: string | number | object;
|
|
35
40
|
}[]>;
|
|
@@ -99,6 +99,13 @@ class MongooseCommonService {
|
|
|
99
99
|
async delete(filter, options = {}) {
|
|
100
100
|
return this.model.updateMany(filter, { deletedBy: options.userId, deletedAt: new Date() }, options).exec();
|
|
101
101
|
}
|
|
102
|
+
async hardDelete(filter, options) {
|
|
103
|
+
return this.model
|
|
104
|
+
.deleteMany(filter, {
|
|
105
|
+
session: options?.session,
|
|
106
|
+
})
|
|
107
|
+
.exec();
|
|
108
|
+
}
|
|
102
109
|
async aggregate(pipeline) {
|
|
103
110
|
return this.model.aggregate(pipeline).exec();
|
|
104
111
|
}
|
|
@@ -13,5 +13,6 @@ export declare class SequelizeCommonService<T extends Model> implements ISequeli
|
|
|
13
13
|
create: (createData: T["_creationAttributes"], options?: CreateOptions) => Promise<T["_attributes"]>;
|
|
14
14
|
bulkCreate: (createData: T["_creationAttributes"][], options?: BulkCreateOptions<T["_attributes"]>) => Promise<T["_attributes"][]>;
|
|
15
15
|
delete: (where: WhereOptions<T["_attributes"]>, options?: DestroyOptions<T["_attributes"]>) => Promise<number>;
|
|
16
|
+
hardDelete: (where: WhereOptions<T["_attributes"]>, options?: Omit<DestroyOptions<T["_attributes"]>, "where">) => Promise<number>;
|
|
16
17
|
count: (where: WhereOptions<T["_attributes"]>, options?: CountOptions<T["_attributes"]>) => Promise<number>;
|
|
17
18
|
}
|
|
@@ -102,6 +102,14 @@ class SequelizeCommonService {
|
|
|
102
102
|
throw err;
|
|
103
103
|
}
|
|
104
104
|
};
|
|
105
|
+
this.hardDelete = async (where, options) => {
|
|
106
|
+
try {
|
|
107
|
+
return this.model.destroy({ where, force: true, ...options });
|
|
108
|
+
}
|
|
109
|
+
catch (err) {
|
|
110
|
+
throw err;
|
|
111
|
+
}
|
|
112
|
+
};
|
|
105
113
|
this.count = (where, options) => {
|
|
106
114
|
try {
|
|
107
115
|
return this.model.count({ where, ...options });
|
|
@@ -30,6 +30,11 @@ interface IDeleteService<T extends Document> {
|
|
|
30
30
|
userId?: string;
|
|
31
31
|
session?: ClientSession;
|
|
32
32
|
}): Promise<UpdateWriteOpResult | null>;
|
|
33
|
+
hardDelete(filter: FilterQuery<T>, options?: MongooseUpdateQueryOptions<T> & {
|
|
34
|
+
session?: ClientSession;
|
|
35
|
+
}): Promise<{
|
|
36
|
+
deletedCount?: number;
|
|
37
|
+
}>;
|
|
33
38
|
}
|
|
34
39
|
export interface IMongooseCommonService<T extends Document> extends IReadService<T>, IWriteService<T>, IDeleteService<T> {
|
|
35
40
|
}
|
|
@@ -15,6 +15,7 @@ interface IWriteService<T extends Model> {
|
|
|
15
15
|
}
|
|
16
16
|
interface IDeleteService<T extends Model> {
|
|
17
17
|
delete(where: WhereOptions<T['_attributes']>, options?: DestroyOptions<T['_attributes']>): Promise<number>;
|
|
18
|
+
hardDelete(where: WhereOptions<T['_attributes']>, options?: DestroyOptions<T['_attributes']>): Promise<number>;
|
|
18
19
|
}
|
|
19
20
|
export interface ISequelizeCommonService<T extends Model> extends IReadService<T>, IWriteService<T>, IDeleteService<T> {
|
|
20
21
|
}
|
package/package.json
CHANGED