User.ts 685 Bytes
import {
  Entity,
  CreateDateColumn,
  PrimaryGeneratedColumn,
  Column,
  ManyToMany,
  JoinTable,
  ManyToOne,
  EntityOptions,
  OneToMany,
  OneToOne
} from "typeorm";

import Dataset from "./Dataset";
import Drone from "./Drone";
import Contract from "./Contract";

@Entity("users")
export default class User {
  @PrimaryGeneratedColumn() id: string;
  @Column() email: string;
  @Column() password: string;

  @OneToMany(type => Drone, drone => drone.owner)
  drones: Array<Drone>;

  @OneToMany(type => Contract, contract => contract.writer)
  contracts: Array<Contract>;

  @ManyToMany(type => Dataset, dataset => dataset.buyers)
  @JoinTable()
  datasets: Array<Dataset>;
}