summary refs log tree commit diff
path: root/src/util/entities/BaseClass.ts
diff options
context:
space:
mode:
authorMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2022-09-26 22:29:30 +1000
committerMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2022-09-26 22:41:21 +1000
commit99ee7e9400f06e8718612d8b52d15215dc620774 (patch)
tree08de8c5d3985b9c2eaa419f5198f891ecd82d012 /src/util/entities/BaseClass.ts
parentRemove the cdn storage location log (diff)
downloadserver-99ee7e9400f06e8718612d8b52d15215dc620774.tar.xz
Prettier
Diffstat (limited to '')
-rw-r--r--src/util/entities/BaseClass.ts36
1 files changed, 30 insertions, 6 deletions
diff --git a/src/util/entities/BaseClass.ts b/src/util/entities/BaseClass.ts

index d5a7c2bf..9942b60e 100644 --- a/src/util/entities/BaseClass.ts +++ b/src/util/entities/BaseClass.ts
@@ -1,5 +1,12 @@ import "reflect-metadata"; -import { BaseEntity, BeforeInsert, BeforeUpdate, FindOptionsWhere, ObjectIdColumn, PrimaryColumn } from "typeorm"; +import { + BaseEntity, + BeforeInsert, + BeforeUpdate, + FindOptionsWhere, + ObjectIdColumn, + PrimaryColumn, +} from "typeorm"; import { Snowflake } from "../util/Snowflake"; import "missing-native-js-functions"; import { getDatabase } from ".."; @@ -22,23 +29,40 @@ export class BaseClassWithoutId extends BaseEntity { toJSON(): any { return Object.fromEntries( this.metadata!.columns // @ts-ignore - .map((x) => [x.propertyName, this[x.propertyName]]) // @ts-ignore - .concat(this.metadata.relations.map((x) => [x.propertyName, this[x.propertyName]])) + .map((x) => [x.propertyName, this[x.propertyName]]) + .concat( + // @ts-ignore + this.metadata.relations.map((x) => [ + x.propertyName, + // @ts-ignore + this[x.propertyName], + ]), + ), ); } - static increment<T extends BaseClass>(conditions: FindOptionsWhere<T>, propertyPath: string, value: number | string) { + static increment<T extends BaseClass>( + conditions: FindOptionsWhere<T>, + propertyPath: string, + value: number | string, + ) { const repository = this.getRepository(); return repository.increment(conditions, propertyPath, value); } - static decrement<T extends BaseClass>(conditions: FindOptionsWhere<T>, propertyPath: string, value: number | string) { + static decrement<T extends BaseClass>( + conditions: FindOptionsWhere<T>, + propertyPath: string, + value: number | string, + ) { const repository = this.getRepository(); return repository.decrement(conditions, propertyPath, value); } } -export const PrimaryIdColumn = process.env.DATABASE?.startsWith("mongodb") ? ObjectIdColumn : PrimaryColumn; +export const PrimaryIdColumn = process.env.DATABASE?.startsWith("mongodb") + ? ObjectIdColumn + : PrimaryColumn; export class BaseClass extends BaseClassWithoutId { @PrimaryIdColumn()