Skip to content

@bb_owned

Syntax

type TypeName @bb_owned {
  ObjectFields
}

Notes

The @bb_owned directive instructs the compiler that the object type is considered an owned object. As a result, the corresponding database table will include a .ownerId column, signifying the owner associated with each record in the table.

Note

Access to a particular owned record is restricted to either the user who owns the record or a user explicitly granted access to that specific user's details. Only these authorized users are allowed to query or modify the designated owned record.

Basic SELECT resolver example
type Patient @bb_owned {
  id: ID!
  name: String
}

This example informs the compiler that all records in the Patient object/table will be considered owned, with the high likelihood that the logged-in user owns the respective records. Consequently, the compiler will generate a .ownerId column in the database. When a patient record is inserted into the database, the compiler will automatically include the IdP user's ID (i.e., the ID of the logged-in user) who created the entry.

Note

If a type is not explicitly owned using @bb_owned/@bb_user/@bb_owned_with_access, it is not owned. This might sound obvious, but it means that any user/role can access the corresponding data records. It is possible to define both owned and unowned types