Skip to content

Commit

Permalink
Added 'updateById'
Browse files Browse the repository at this point in the history
  • Loading branch information
acrodrig committed Oct 26, 2023
1 parent 35bb918 commit 94ff374
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,11 @@ export class Repository<T extends Identifiable> extends EventTarget {
return result.affectedRows === 1 ? object as T : undefined;
}

// https://dev.mysql.com/doc/refman/8.0/en/update.html
updateById(id: number | string, object: Partial<T>, debug = false): Promise<T | undefined> {
return this.update({ ...object, id }, debug);
}

toRecord(object: Partial<T>, record: Record<string, unknown> = {}): Record<string, unknown> {
const columns = this.schema?.properties;
const names = Object.keys(columns ?? object);
Expand Down

0 comments on commit 94ff374

Please sign in to comment.