Open whitered932 opened 2 years ago
Hello! I have such an entity -
import { IModeratable, IUpdatable } from '~/@common/entity'; import { Column, CreateDateColumn, Entity, ManyToOne, PrimaryGeneratedColumn, Unique, UpdateDateColumn, } from '~/@core/orm'; import { IngredientEntity } from '~/ingredient/ingredient.entity'; import { RecipeEntity } from '~/recipe/recipe.entity'; import { Rule } from '~/rule/rule.types'; import { UnitEntity } from '~/unit/unit.entity'; @Unique(['recipe', 'unit', 'ingredient']) @Entity() export class RecipeIngredientEntity { @PrimaryGeneratedColumn() id: string; @Column() amount: number; @ManyToOne(() => RecipeEntity, (recipe) => recipe.ingredients) recipe: RecipeEntity; @ManyToOne(() => UnitEntity, (unit) => unit.recipeIngredients) unit: UnitEntity; @ManyToOne( () => IngredientEntity, (ingredient) => ingredient.recipeIngredients, ) ingredient: IngredientEntity; }
I know that i can create relations like this:
{ "title": "Some title", "description": "Some description", "ingredients": [ {"id": "some id"} ] }
but I want to create a record like this:
{ "title": "Some title", "description": "Some description", "ingredients": [ {"unit": "some id", "amount": 12, "ingredient": "some id"} ] }
Is there a built-in way? i tried this syntax
{"unit": "some id", "amount": 12, "ingredient": "some id"}, {"unitId": "some id", "amount": 12, "ingredientId": "some id"}
Hello! I have such an entity -
I know that i can create relations like this:
but I want to create a record like this:
Is there a built-in way? i tried this syntax