From 3731934e34b5e423bbf409ecf2e49a635d4f0a2c Mon Sep 17 00:00:00 2001 From: jongwoo Yoo Date: Sat, 28 Dec 2024 05:24:46 +0900 Subject: [PATCH] Update polymorphic-associations.md change from `@Attributes` to `@Attribute` change from `constraints: false` to `foreignKeyConstraints: false` --- docs/associations/polymorphic-associations.md | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/docs/associations/polymorphic-associations.md b/docs/associations/polymorphic-associations.md index 619bdbe30..242e117e9 100644 --- a/docs/associations/polymorphic-associations.md +++ b/docs/associations/polymorphic-associations.md @@ -34,11 +34,11 @@ abstract class AbstractComment extends Model< > { declare id: number; - @Attributes(DataTypes.STRING) + @Attribute(DataTypes.STRING) @NotNull declare content: string; - @Attributes(DataTypes.INTEGER) + @Attribute(DataTypes.INTEGER) @NotNull declare targetId: number; } @@ -72,17 +72,17 @@ This solution only requires a single table, to which we add multiple, mutually-e class Comment extends Model, InferCreationAttributes> { declare id: number; - @Attributes(DataTypes.STRING) + @Attribute(DataTypes.STRING) @NotNull declare content: string; - @Attributes(DataTypes.INTEGER) + @Attribute(DataTypes.INTEGER) declare articleId: number | null; @BelongsTo(() => Article, 'articleId') declare article?: Article; - @Attributes(DataTypes.INTEGER) + @Attribute(DataTypes.INTEGER) declare videoId: number | null; @BelongsTo(() => Video, 'videoId') @@ -111,7 +111,7 @@ In this type of polymorphic association, we don't use foreign keys at all. Instead, we use two columns: one to store the type of the associated model, and one to store the ID of the associated model. As stated above, we must disable the foreign key constraints on the association, as the same column is referencing multiple tables. -This can be done by using the `constraints: false`. +This can be done by using the `foreignKeyConstraints: false`. We then use [association scopes](./association-scopes.md) to filter which comments belong to which models. @@ -119,15 +119,15 @@ We then use [association scopes](./association-scopes.md) to filter which commen class Comment extends Model, InferCreationAttributes> { declare id: number; - @Attributes(DataTypes.STRING) + @Attribute(DataTypes.STRING) @NotNull declare content: string; - @Attributes(DataTypes.STRING) + @Attribute(DataTypes.STRING) @NotNull declare targetModel: 'article' | 'video'; - @Attributes(DataTypes.INTEGER) + @Attribute(DataTypes.INTEGER) @NotNull declare targetId: number; @@ -156,7 +156,7 @@ class Video extends Model, InferCreationAttributes