2018-07-20 00:03:11 -06:00
|
|
|
import { Column, Entity, ManyToMany, PrimaryGeneratedColumn } from "typeorm";
|
|
|
|
|
2018-08-12 11:55:15 +03:00
|
|
|
import { ISprinklersDevice } from "@common/httpApi";
|
2018-07-20 00:03:11 -06:00
|
|
|
import { User } from "./User";
|
|
|
|
|
|
|
|
@Entity()
|
2018-08-12 11:55:15 +03:00
|
|
|
export class SprinklersDevice implements ISprinklersDevice {
|
2018-09-02 02:57:55 -06:00
|
|
|
@PrimaryGeneratedColumn()
|
|
|
|
id!: number;
|
2018-07-20 00:03:11 -06:00
|
|
|
|
2018-09-02 02:57:55 -06:00
|
|
|
@Column({ unique: true, nullable: true, type: "varchar" })
|
|
|
|
deviceId: string | null = null;
|
2018-07-23 19:20:41 -06:00
|
|
|
|
2018-09-02 02:57:55 -06:00
|
|
|
@Column()
|
|
|
|
name: string = "";
|
2018-07-20 00:03:11 -06:00
|
|
|
|
2018-09-02 02:57:55 -06:00
|
|
|
@ManyToMany(type => User)
|
|
|
|
users: User[] | undefined;
|
2018-07-20 00:03:11 -06:00
|
|
|
|
2018-09-02 02:57:55 -06:00
|
|
|
constructor(data?: Partial<SprinklersDevice>) {
|
|
|
|
if (data) {
|
|
|
|
Object.assign(this, data);
|
2018-07-20 00:03:11 -06:00
|
|
|
}
|
2018-09-02 02:57:55 -06:00
|
|
|
}
|
2018-07-20 00:03:11 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
// @Entity()
|
|
|
|
export class UserSprinklersDevice {
|
2018-09-02 02:57:55 -06:00
|
|
|
@PrimaryGeneratedColumn()
|
|
|
|
id!: number;
|
|
|
|
|
|
|
|
@Column()
|
|
|
|
userId: string = "";
|
|
|
|
@Column()
|
|
|
|
sprinklersDeviceId: string = "";
|
|
|
|
|
|
|
|
constructor(data?: UserSprinklersDevice) {
|
|
|
|
if (data) {
|
|
|
|
Object.assign(this, data);
|
2018-07-20 00:03:11 -06:00
|
|
|
}
|
2018-09-02 02:57:55 -06:00
|
|
|
}
|
2018-07-20 00:03:11 -06:00
|
|
|
}
|