Skip to content

Commit

Permalink
refactor(app.queries): always execute app updates
Browse files Browse the repository at this point in the history
  • Loading branch information
nicotsx committed Dec 7, 2023
1 parent 1978abd commit 678e63f
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/server/queries/apps/apps.queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class AppQueries {
* @param {Partial<NewApp>} data - The data to update the app with
*/
public async updateApp(appId: string, data: Partial<NewApp>) {
const updatedApps = await this.db.update(appTable).set(data).where(eq(appTable.id, appId)).returning();
const updatedApps = await this.db.update(appTable).set(data).where(eq(appTable.id, appId)).returning().execute();
return updatedApps[0];
}

Expand All @@ -35,7 +35,7 @@ export class AppQueries {
* @param {string} appId - The id of the app to delete
*/
public async deleteApp(appId: string) {
await this.db.delete(appTable).where(eq(appTable.id, appId));
await this.db.delete(appTable).where(eq(appTable.id, appId)).execute();
}

/**
Expand Down Expand Up @@ -68,7 +68,10 @@ export class AppQueries {
* Returns all apps that are running and visible on guest dashboard sorted by id ascending
*/
public async getGuestDashboardApps() {
return this.db.query.appTable.findMany({ where: and(eq(appTable.status, 'running'), eq(appTable.isVisibleOnGuestDashboard, true)), orderBy: asc(appTable.id) });
return this.db.query.appTable.findMany({
where: and(eq(appTable.status, 'running'), eq(appTable.isVisibleOnGuestDashboard, true)),
orderBy: asc(appTable.id),
});
}

/**
Expand All @@ -88,6 +91,6 @@ export class AppQueries {
* @param {Partial<NewApp>} data - The data to update the apps with
*/
public async updateAppsByStatusNotIn(statuses: AppStatus[], data: Partial<NewApp>) {
return this.db.update(appTable).set(data).where(notInArray(appTable.status, statuses)).returning();
return this.db.update(appTable).set(data).where(notInArray(appTable.status, statuses)).returning().execute();
}
}

0 comments on commit 678e63f

Please sign in to comment.