Skip to content

Commit

Permalink
Rename insertOrUpdate to upsert
Browse files Browse the repository at this point in the history
  • Loading branch information
TrojanerHD committed Mar 18, 2023
1 parent f35accc commit 57fde45
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/settings/DatabaseHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default abstract class DatabaseHelper<T extends HasId> {
* @param tableName The table to insert or update to
* @param data The data to insert or update
*/
protected async insertOrUpdate(tableName: string, data: T): Promise<void> {
protected async upsert(tableName: string, data: T): Promise<void> {
const id = data.id;
const rows = await this.select(tableName, ['id'], `id = ${id}`);
if (rows.length === 0) return this.insert(tableName, data);
Expand Down
2 changes: 1 addition & 1 deletion src/settings/SettingsDB.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export default class SettingsDB extends DatabaseHelper<DatabaseGuildInfo> {
streamers: JSON.stringify(data.streamers),
};

return this.insertOrUpdate('server', mappedData);
return this.upsert('server', mappedData);
}

/**
Expand Down

0 comments on commit 57fde45

Please sign in to comment.