Browse Source

Fix typeorm relations

develop
Alex Mikhalev 6 years ago
parent
commit
b987e49beb
  1. 2
      server/entities/SprinklersDevice.ts
  2. 2
      server/entities/User.ts

2
server/entities/SprinklersDevice.ts

@ -14,7 +14,7 @@ export class SprinklersDevice implements ISprinklersDevice { @@ -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<SprinklersDevice>) {

2
server/entities/User.ts

@ -29,7 +29,7 @@ export class User implements IUser { @@ -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;

Loading…
Cancel
Save