- Get Started
- Product
- Resources
- Tools & SDKs
- Framework
- Reference
Menu
- Get Started
- Product
- Resources
- Tools & SDKs
- Framework
- Reference
hasOne Relationship Method - DML Reference
hasOne<TypeParameter T>(entityBuilder, options): HasOneWithForeignKey<T>#
This method defines a relationship between two data models, where the owner of the relationship has one record of the related data model.
For example: A user "hasOne" email.
Use the belongsTo method to define the inverse of this relationship in the other data model.
Example#
Type Parameters#
T
objectOptionalThe type of the entity builder passed as a first parameter. By default, it's
a function returning the related model.
Parameters#
entityBuilder
TA function that returns the data model this model is related to.
options
object & Record<string, any> & objectThe relationship's options.
options
object & Record<string, any> & objecthasOne<TypeParameter T>(entityBuilder, options?): HasOne<T>#
Type Parameters#
T
objectOptionalParameters#
entityBuilder
Toptions
object & Record<string, any> & objectOptional
options
object & Record<string, any> & objectOptionalWas this page helpful?