added format command and added trailing commas to reduce conflicts

This commit is contained in:
dswbx
2025-02-26 20:06:03 +01:00
parent 88b5359f1c
commit 7743f71a11
414 changed files with 3622 additions and 3610 deletions
+12 -12
View File
@@ -29,7 +29,7 @@ export class Mutator<
TBD extends object = DefaultDB,
TB extends keyof TBD = any,
Output = TBD[TB],
Input = Omit<Output, "id">
Input = Omit<Output, "id">,
> implements EmitsEvents
{
em: EntityManager<TBD>;
@@ -85,7 +85,7 @@ export class Mutator<
`Field "${key}" not found on entity "${entity.name}". Fields: ${entity
.getFillableFields()
.map((f) => f.name)
.join(", ")}`
.join(", ")}`,
);
}
@@ -118,7 +118,7 @@ export class Mutator<
sql,
parameters: [...parameters],
result: result,
data
data,
};
} catch (e) {
// @todo: redact
@@ -139,14 +139,14 @@ export class Mutator<
}
const result = await this.emgr.emit(
new Mutator.Events.MutatorInsertBefore({ entity, data: data as any })
new Mutator.Events.MutatorInsertBefore({ entity, data: data as any }),
);
// if listener returned, take what's returned
const _data = result.returned ? result.params.data : data;
const validatedData = {
...entity.getDefaultObject(),
...(await this.getValidatedData(_data, "create"))
...(await this.getValidatedData(_data, "create")),
};
// check if required fields are present
@@ -182,8 +182,8 @@ export class Mutator<
new Mutator.Events.MutatorUpdateBefore({
entity,
entityId: id,
data
})
data,
}),
);
const _data = result.returned ? result.params.data : data;
@@ -198,7 +198,7 @@ export class Mutator<
const res = await this.single(query);
await this.emgr.emit(
new Mutator.Events.MutatorUpdateAfter({ entity, entityId: id, data: res.data })
new Mutator.Events.MutatorUpdateAfter({ entity, entityId: id, data: res.data }),
);
return res as any;
@@ -220,7 +220,7 @@ export class Mutator<
const res = await this.single(query);
await this.emgr.emit(
new Mutator.Events.MutatorDeleteAfter({ entity, entityId: id, data: res.data })
new Mutator.Events.MutatorDeleteAfter({ entity, entityId: id, data: res.data }),
);
return res as any;
@@ -274,7 +274,7 @@ export class Mutator<
const entity = this.entity;
const qb = this.appendWhere(this.conn.deleteFrom(entity.name), where).returning(
entity.getSelect()
entity.getSelect(),
);
return (await this.many(qb)) as any;
@@ -282,7 +282,7 @@ export class Mutator<
async updateWhere(
data: Partial<Input>,
where?: RepoQuery["where"]
where?: RepoQuery["where"],
): Promise<MutatorResponse<Output[]>> {
const entity = this.entity;
const validatedData = await this.getValidatedData(data, "update");
@@ -304,7 +304,7 @@ export class Mutator<
for (const row of data) {
const validatedData = {
...entity.getDefaultObject(),
...(await this.getValidatedData(row, "create"))
...(await this.getValidatedData(row, "create")),
};
// check if required fields are present