From b987e49beb7d47967f437febe3454a37204e317f Mon Sep 17 00:00:00 2001 From: Alex Mikhalev Date: Fri, 19 Jul 2019 23:59:43 -0600 Subject: [PATCH] Fix typeorm relations --- server/entities/SprinklersDevice.ts | 2 +- server/entities/User.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/server/entities/SprinklersDevice.ts b/server/entities/SprinklersDevice.ts index 42ab082..0499313 100644 --- a/server/entities/SprinklersDevice.ts +++ b/server/entities/SprinklersDevice.ts @@ -14,7 +14,7 @@ export class SprinklersDevice implements ISprinklersDevice { @Column() name: string = ""; - @ManyToMany(type => User) + @ManyToMany(type => User, user => user.devices) users: User[] | undefined; constructor(data?: Partial) { diff --git a/server/entities/User.ts b/server/entities/User.ts index 4318ef1..bc2d701 100644 --- a/server/entities/User.ts +++ b/server/entities/User.ts @@ -29,7 +29,7 @@ export class User implements IUser { @Column() passwordHash: string = ""; - @ManyToMany(type => SprinklersDevice) + @ManyToMany(type => SprinklersDevice, device => device.users) @JoinTable({ name: "user_sprinklers_device" }) devices: SprinklersDevice[] | undefined;