recipe-backend/src/entities/RecipeIngredientEntity.ts
2025-09-27 18:21:10 +02:00

29 lines
No EOL
825 B
TypeScript

import { Column, Entity, 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({ nullable: false })
sortOrder!: number;
@ManyToOne(() => RecipeIngredientGroupEntity, (ingredientGroup) => ingredientGroup.ingredients,
{onDelete: "CASCADE"}
)
ingredientGroup!: Relation<RecipeIngredientGroupEntity>;
}