Relationships
Connections between tables
One-to-One
import {
Boolean,
Column,
OneToOne,
PrimaryGeneratedColumn,
String,
Table
} from "@myroslavshymon/orm";
import {Sections} from "./sections";
@Table({name: 'users'})
export class Users {
@PrimaryGeneratedColumn({type: 'BIGINT'})
user_id: number;
@String({type: "VARCHAR", length: 255})
@Column({options: {unique: true, nullable: false}})
username: string;
@String({type: "VARCHAR", length: 255})
@Column({options: {nullable: false}})
email: string;
@String({type: "VARCHAR", length: 255})
@Column({options: {nullable: false}})
password: string;
@Column({options: {dataType: 'BOOLEAN', defaultValue: false}})
is_active: boolean;
@Column({options: {dataType: "BIGINT"}})
section_id: number;
@OneToOne({ table: 'sections', foreignKey: 'section_id', referenceColumn: 'section_id' })
section: Sections;
}One-to-Many
Many-to-Many
ForeignKey
Last updated