Skip to content

Class: abstract RelationshipBase<R, OM, TM, PKT, FM, PKF, T, F>

The base class for all relationships

Remarks

Relationships are defined during runtime by adding them to the ReactiveDatabaseModelDefinition under the relationships property, where the key is the name of the relationship, and the value is an instance of the relationship class which defines how the relationship works. For example:

typescript
{
  ...
     relationships: {
        user: [BelongsTo, 'users', 'user_id'], 
     }
  ...
}

Extended by

Type Parameters

Type ParameterDefault typeDescription
R-type of value returned by the relationship
OM extends Record<string, PlainObject>-the map of all models in the database
TM extends StringKeyOf<OM>-the table of the originating model
PKT extends StringKeyOf<OM[TM]>-the property used as the primary key in the originating model
FM extends StringKeyOf<OM>-the table of the foreign model
PKF extends StringKeyOf<OM[FM]>-the property used as the primary key in the foreign model
T extends PlainObjectOM[TM]the type of the originating model
F extends PlainObjectOM[FM]the type of the foreign model