61 lines
1.1 KiB
TypeScript
61 lines
1.1 KiB
TypeScript
import { User } from 'src/objects/user/user.entity';
|
|
import {
|
|
Column,
|
|
CreateDateColumn,
|
|
Entity,
|
|
ManyToOne,
|
|
OneToMany,
|
|
PrimaryGeneratedColumn,
|
|
UpdateDateColumn,
|
|
} from 'typeorm';
|
|
import { ItemType } from '../enums/item-type.enum';
|
|
import { StoredItem } from './stored-item.entity';
|
|
|
|
@Entity()
|
|
export class Item {
|
|
@PrimaryGeneratedColumn()
|
|
id: number;
|
|
|
|
@Column()
|
|
displayName: string;
|
|
|
|
@Column({ type: String, default: ItemType.ITEM })
|
|
type: ItemType;
|
|
|
|
@Column({ nullable: true })
|
|
barcode?: string;
|
|
|
|
@Column({ default: false })
|
|
consumable: boolean;
|
|
|
|
@Column({ nullable: true })
|
|
image?: string;
|
|
|
|
@Column({ nullable: true })
|
|
weight?: number;
|
|
|
|
@Column({ nullable: true })
|
|
url?: string;
|
|
|
|
@Column({ nullable: true })
|
|
notes?: string;
|
|
|
|
@OneToMany(() => StoredItem, (store) => store.item)
|
|
instances?: StoredItem[];
|
|
|
|
@ManyToOne(() => User, {
|
|
onDelete: 'SET NULL',
|
|
nullable: true,
|
|
})
|
|
addedBy: User;
|
|
|
|
@Column({ default: false })
|
|
public: boolean;
|
|
|
|
@CreateDateColumn()
|
|
createdAt: Date;
|
|
|
|
@UpdateDateColumn()
|
|
updatedAt: Date;
|
|
}
|