mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-16 04:27:21 +00:00
module manager: switched config table to use entity
This commit is contained in:
@@ -250,7 +250,7 @@ export class Mutator<DB> implements EmitsEvents {
|
||||
}
|
||||
|
||||
// @todo: decide whether entries should be deleted all at once or one by one (for events)
|
||||
async deleteMany(where?: RepoQuery["where"]): Promise<MutatorResponse<EntityData>> {
|
||||
async deleteWhere(where?: RepoQuery["where"]): Promise<MutatorResponse<EntityData>> {
|
||||
const entity = this.entity;
|
||||
|
||||
const qb = this.appendWhere(this.conn.deleteFrom(entity.name), where).returning(
|
||||
@@ -267,4 +267,30 @@ export class Mutator<DB> implements EmitsEvents {
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
async updateWhere(
|
||||
data: EntityData,
|
||||
where?: RepoQuery["where"]
|
||||
): Promise<MutatorResponse<EntityData>> {
|
||||
const entity = this.entity;
|
||||
|
||||
const validatedData = await this.getValidatedData(data, "update");
|
||||
|
||||
/*await this.emgr.emit(
|
||||
new Mutator.Events.MutatorUpdateBefore({ entity, entityId: id, data: validatedData })
|
||||
);*/
|
||||
|
||||
const query = this.appendWhere(this.conn.updateTable(entity.name), where)
|
||||
.set(validatedData)
|
||||
//.where(entity.id().name, "=", id)
|
||||
.returning(entity.getSelect());
|
||||
|
||||
const res = await this.many(query);
|
||||
|
||||
/*await this.emgr.emit(
|
||||
new Mutator.Events.MutatorUpdateAfter({ entity, entityId: id, data: res.data })
|
||||
);*/
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user