You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
883 B

import { Column, Entity, ManyToMany, PrimaryGeneratedColumn } from "typeorm";
import { ISprinklersDevice } from "@common/httpApi";
import { User } from "./User";
@Entity()
export class SprinklersDevice implements ISprinklersDevice {
@PrimaryGeneratedColumn()
id!: number;
@Column({ unique: true, nullable: true, type: "varchar" })
deviceId: string | null = null;
@Column()
name: string = "";
@ManyToMany(type => User, user => user.devices)
users: User[] | undefined;
constructor(data?: Partial<SprinklersDevice>) {
if (data) {
Object.assign(this, data);
}
}
}
// @Entity()
export class UserSprinklersDevice {
@PrimaryGeneratedColumn()
id!: number;
@Column()
userId: string = "";
@Column()
sprinklersDeviceId: string = "";
constructor(data?: UserSprinklersDevice) {
if (data) {
Object.assign(this, data);
}
}
}