refactor: 🚨 Remove unnecessary function overloads

This commit is contained in:
Jesse Wierzbinski 2024-10-03 13:54:09 +02:00
parent 835cdc3f18
commit 5ec19f037a
No known key found for this signature in database
8 changed files with 9 additions and 29 deletions

View file

@ -124,9 +124,7 @@ export class Attachment extends BaseInterface<typeof Attachments> {
return this.update(this.data);
}
async delete(ids: string[]): Promise<void>;
async delete(): Promise<void>;
async delete(ids?: unknown): Promise<void> {
async delete(ids?: string[]): Promise<void> {
if (Array.isArray(ids)) {
await db.delete(Attachments).where(inArray(Attachments.id, ids));
} else {

View file

@ -30,16 +30,10 @@ export abstract class BaseInterface<
/**
* Deletes the model from the database.
*
* @param ids - The ids of the models to delete.
* @param ids - The ids of the models to delete. If not provided, the current model will be deleted.
* @returns A promise that resolves when the deletion is complete.
*/
public abstract delete(ids: string[]): Promise<void>;
/**
* Deletes the model from the database.
*
* @returns A promise that resolves when the deletion is complete.
*/
public abstract delete(): Promise<void>;
public abstract delete(ids?: string[]): Promise<void>;
/**
* Updates the model with new data.

View file

@ -107,9 +107,7 @@ export class Emoji extends BaseInterface<typeof Emojis, EmojiWithInstance> {
return this.update(this.data);
}
async delete(ids: string[]): Promise<void>;
async delete(): Promise<void>;
async delete(ids?: unknown): Promise<void> {
async delete(ids?: string[]): Promise<void> {
if (Array.isArray(ids)) {
await db.delete(Emojis).where(inArray(Emojis.id, ids));
} else {

View file

@ -101,9 +101,7 @@ export class Instance extends BaseInterface<typeof Instances> {
return this.update(this.data);
}
async delete(ids: string[]): Promise<void>;
async delete(): Promise<void>;
async delete(ids?: unknown): Promise<void> {
async delete(ids?: string[]): Promise<void> {
if (Array.isArray(ids)) {
await db.delete(Instances).where(inArray(Instances.id, ids));
} else {

View file

@ -810,9 +810,7 @@ export class Note extends BaseInterface<typeof Notes, StatusWithRelations> {
return await Note.fromData(newData);
}
async delete(ids: string[]): Promise<void>;
async delete(): Promise<void>;
async delete(ids?: unknown): Promise<void> {
async delete(ids?: string[]): Promise<void> {
if (Array.isArray(ids)) {
await db.delete(Notes).where(inArray(Notes.id, ids));
} else {

View file

@ -254,9 +254,7 @@ export class Relationship extends BaseInterface<
return this.update(this.data);
}
async delete(ids: string[]): Promise<void>;
async delete(): Promise<void>;
async delete(ids?: unknown): Promise<void> {
async delete(ids?: string[]): Promise<void> {
if (Array.isArray(ids)) {
await db
.delete(Relationships)

View file

@ -143,9 +143,7 @@ export class Role extends BaseInterface<typeof Roles> {
return this.update(this.data);
}
async delete(ids: string[]): Promise<void>;
async delete(): Promise<void>;
async delete(ids?: unknown): Promise<void> {
async delete(ids?: string[]): Promise<void> {
if (Array.isArray(ids)) {
await db.delete(Roles).where(inArray(Roles.id, ids));
} else {

View file

@ -358,9 +358,7 @@ export class User extends BaseInterface<typeof Users, UserWithRelations> {
)[0].count;
}
async delete(ids: string[]): Promise<void>;
async delete(): Promise<void>;
async delete(ids?: unknown): Promise<void> {
async delete(ids?: string[]): Promise<void> {
if (Array.isArray(ids)) {
await db.delete(Users).where(inArray(Users.id, ids));
} else {