diff options
Diffstat (limited to 'util/src/entities')
-rw-r--r-- | util/src/entities/BaseClass.ts | 8 | ||||
-rw-r--r-- | util/src/entities/Config.ts | 10 | ||||
-rw-r--r-- | util/src/entities/Invite.ts | 8 | ||||
-rw-r--r-- | util/src/entities/Member.ts | 2 | ||||
-rw-r--r-- | util/src/entities/Template.ts | 2 |
5 files changed, 14 insertions, 16 deletions
diff --git a/util/src/entities/BaseClass.ts b/util/src/entities/BaseClass.ts index d18757f2..f105086a 100644 --- a/util/src/entities/BaseClass.ts +++ b/util/src/entities/BaseClass.ts @@ -5,10 +5,8 @@ import { BeforeUpdate, EntityMetadata, FindConditions, - getConnection, - getManager, + ObjectIdColumn, PrimaryColumn, - RemoveOptions, } from "typeorm"; import { Snowflake } from "../util/Snowflake"; import "missing-native-js-functions"; @@ -117,8 +115,10 @@ export class BaseClassWithoutId extends BaseEntity { // } } +export const PrimaryIdColumn = process.env.DATABASE?.startsWith("mongodb") ? ObjectIdColumn : PrimaryColumn; + export class BaseClass extends BaseClassWithoutId { - @PrimaryColumn() + @PrimaryIdColumn() id: string; assign(props: any = {}) { diff --git a/util/src/entities/Config.ts b/util/src/entities/Config.ts index edce92a9..28926233 100644 --- a/util/src/entities/Config.ts +++ b/util/src/entities/Config.ts @@ -1,11 +1,11 @@ -import { Column, Entity, JoinColumn, ManyToOne, PrimaryColumn } from "typeorm"; -import { BaseClass, BaseClassWithoutId } from "./BaseClass"; +import { Column, Entity } from "typeorm"; +import { BaseClassWithoutId, PrimaryIdColumn } from "./BaseClass"; import crypto from "crypto"; import { Snowflake } from "../util/Snowflake"; @Entity("config") export class ConfigEntity extends BaseClassWithoutId { - @PrimaryColumn() + @PrimaryIdColumn() key: string; @Column({ type: "simple-json", nullable: true }) @@ -144,7 +144,7 @@ export interface ConfigValue { useDefaultAsOptimal: boolean; available: Region[]; }; - + guild: { showAllGuildsInDiscovery: boolean; }; @@ -299,7 +299,7 @@ export const DefaultConfigOptions: ConfigValue = { }, ], }, - + guild: { showAllGuildsInDiscovery: false, }, diff --git a/util/src/entities/Invite.ts b/util/src/entities/Invite.ts index 78545b02..82556fab 100644 --- a/util/src/entities/Invite.ts +++ b/util/src/entities/Invite.ts @@ -1,6 +1,6 @@ -import { Column, Entity, JoinColumn, ManyToOne, PrimaryColumn, RelationId } from "typeorm"; -import { Member } from "."; -import { BaseClass } from "./BaseClass"; +import { Column, Entity, JoinColumn, ManyToOne, RelationId } from "typeorm"; +import { Member } from "./Member"; +import { BaseClass, PrimaryIdColumn } from "./BaseClass"; import { Channel } from "./Channel"; import { Guild } from "./Guild"; import { User } from "./User"; @@ -9,7 +9,7 @@ export const PublicInviteRelation = ["inviter", "guild", "channel"]; @Entity("invites") export class Invite extends BaseClass { - @PrimaryColumn() + @PrimaryIdColumn() code: string; @Column() diff --git a/util/src/entities/Member.ts b/util/src/entities/Member.ts index feb9c069..7d7ac40a 100644 --- a/util/src/entities/Member.ts +++ b/util/src/entities/Member.ts @@ -8,8 +8,6 @@ import { JoinTable, ManyToMany, ManyToOne, - OneToMany, - PrimaryColumn, PrimaryGeneratedColumn, RelationId, } from "typeorm"; diff --git a/util/src/entities/Template.ts b/util/src/entities/Template.ts index c9c32f42..1d952283 100644 --- a/util/src/entities/Template.ts +++ b/util/src/entities/Template.ts @@ -1,4 +1,4 @@ -import { Column, Entity, Index, JoinColumn, ManyToOne, PrimaryColumn, RelationId } from "typeorm"; +import { Column, Entity, JoinColumn, ManyToOne, RelationId } from "typeorm"; import { BaseClass } from "./BaseClass"; import { Guild } from "./Guild"; import { User } from "./User"; |