hasOne Relationship Method - API Reference

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#

Code
1import { model } from "@medusajs/framework/utils"2
3const User = model.define("user", {4  id: model.id(),5  email: model.hasOne(() => Email),6})

Type Parameters#

Loading...

Parameters#

Loading...
Was this page helpful?