Skip to content

Commit

Permalink
feat(update): minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
mgcrea committed May 18, 2024
1 parent 467015e commit 1bfe989
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/PrismaJob.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class PrismaJob<T, U> {
}
}

public get record() {
public get record(): DatabaseJob<T, U> {
return this.#record;
}
public get key() {
Expand All @@ -50,19 +50,19 @@ export class PrismaJob<T, U> {
return this.#record.error;
}

public async progress(progress: number) {
public async progress(progress: number): Promise<DatabaseJob<T, U>> {
return await this.update({ progress: Math.max(0, Math.min(100, progress)) });
}

public async fetch() {
public async fetch(): Promise<DatabaseJob<T, U>> {
const record = (await this.#model.findUnique({
where: { id: this.id },
})) as DatabaseJob<T, U>;
this.#assign(record);
return record;
}

public async update(data: Prisma.QueueJobUpdateInput) {
public async update(data: Prisma.QueueJobUpdateInput): Promise<DatabaseJob<T, U>> {
const record = (await this.#model.update({
where: { id: this.id },
data,
Expand All @@ -71,7 +71,7 @@ export class PrismaJob<T, U> {
return record;
}

public async delete() {
public async delete(): Promise<DatabaseJob<T, U>> {
const record = (await this.#model.delete({
where: { id: this.id },
})) as DatabaseJob<T, U>;
Expand Down

0 comments on commit 1bfe989

Please sign in to comment.