recipe-backend/src/entities/RecipeIngredientEntity.ts
2025-09-28 12:24:59 +02:00

30 lines
No EOL
928 B
TypeScript

import { Column, Entity, JoinColumn, ManyToOne, Relation} from "typeorm";
import { AbstractEntity } from "./AbstractEntity.js";
import { RecipeIngredientGroupEntity } from "./RecipeIngredientGroupEntity.js";
/**
* Entity describing an ingredient group for a recipe
*/
@Entity({ name: "recipe_ingredient" })
export class RecipeIngredientEntity extends AbstractEntity {
@Column({ nullable: false })
name!: string;
@Column({nullable: true})
subtext?: string;
@Column({nullable: true})
amount?: number;
@Column({nullable: true})
unit?: string;
@Column({ name: "sort_order", nullable: false })
sortOrder!: number;
@JoinColumn({name: "recipe_ingredient_group_id"})
@ManyToOne(() => RecipeIngredientGroupEntity, (ingredientGroup) => ingredientGroup.ingredients,
{onDelete: "CASCADE", nullable: false}
)
ingredientGroup!: Relation<RecipeIngredientGroupEntity>;
}