You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/docs/models/relationships.md
+9-9Lines changed: 9 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -82,7 +82,7 @@ By default, the `foreignKey` is the **snake_case representation of the parent mo
82
82
@hasOne(() =>Profile, {
83
83
foreignKey: 'profileUserId', // defaults to userId
84
84
})
85
-
profile: HasOne<typeofProfile>
85
+
declareprofile: HasOne<typeofProfile>
86
86
```
87
87
88
88
:::note
@@ -95,7 +95,7 @@ The local key is always the **primary key of the parent model** but can also be
95
95
@hasOne(() =>Profile, {
96
96
localKey: 'uuid', // defaults to id
97
97
})
98
-
profile: HasOne<typeofProfile>
98
+
declareprofile: HasOne<typeofProfile>
99
99
```
100
100
101
101
## HasMany
@@ -178,7 +178,7 @@ By default, the `foreignKey` is the **camelCase representation of the parent mod
178
178
@hasMany(() =>Post, {
179
179
foreignKey: 'authorId', // defaults to userId
180
180
})
181
-
posts: HasMany<typeofPost>
181
+
declareposts: HasMany<typeofPost>
182
182
```
183
183
184
184
:::note
@@ -191,7 +191,7 @@ The local key is always the **primary key of the parent model** but can also be
191
191
@hasMany(() =>Post, {
192
192
localKey: 'uuid', // defaults to id
193
193
})
194
-
posts: HasMany<typeofPost>
194
+
declareposts: HasMany<typeofPost>
195
195
```
196
196
197
197
## BelongsTo
@@ -342,7 +342,7 @@ A manyToMany relation relies on many different keys to properly set up the relat
342
342
relatedKey: 'id',
343
343
pivotRelatedForeignKey: 'skill_id',
344
344
})
345
-
skills: ManyToMany<typeofSkill>
345
+
declareskills: ManyToMany<typeofSkill>
346
346
```
347
347
348
348
:::note
@@ -357,7 +357,7 @@ The default value for the pivot table name is computed by [combining](https://gi
357
357
@manyToMany(() =>Skill, {
358
358
pivotTable: 'user_skills',
359
359
})
360
-
skills: ManyToMany<typeofSkill>
360
+
declareskills: ManyToMany<typeofSkill>
361
361
```
362
362
363
363
### Additional pivot columns
@@ -370,7 +370,7 @@ You will have to inform a manyToMany relationship about this extra column. Other
370
370
@manyToMany(() =>Skill, {
371
371
pivotColumns: ['proficiency'],
372
372
})
373
-
skills: ManyToMany<typeofSkill>
373
+
declareskills: ManyToMany<typeofSkill>
374
374
```
375
375
376
376
### Pivot table timestamps
@@ -384,7 +384,7 @@ You can enable the support for **created at** and **updated at** timestamps for
384
384
@manyToMany(() =>Skill, {
385
385
pivotTimestamps: true
386
386
})
387
-
skills: ManyToMany<typeofSkill>
387
+
declareskills: ManyToMany<typeofSkill>
388
388
```
389
389
390
390
Settings `pivotTimestamps = true` assumes the column names are defined as `created_at` and `updated_at`. However, you can define custom column names as well.
@@ -396,7 +396,7 @@ Settings `pivotTimestamps = true` assumes the column names are defined as `creat
396
396
updatedAt: 'updation_date'
397
397
}
398
398
})
399
-
skills: ManyToMany<typeofSkill>
399
+
declareskills: ManyToMany<typeofSkill>
400
400
```
401
401
402
402
To disable a particular timestamp, you can set its value to `false`.
0 commit comments