Skip to content

Derive relationshipMappings using SubClass #2

Description

@djamez

Hello,

The package does not appear to work where the classes being used extend a higher base model. For example, I have the following hierarchy:

export class Employee extends PayrollBaseModel { ... }

export class PayrollBaseModel extends Model { ... }

This becomes necessary in my case because my application is multi-db, and the PayrollBaseModel is bound to a knex instance pointing to the Payroll DB.

   static relationMappings = new ModelRelationshipFacade(Employee)
        .belongsToOne(Department)
        .getRelationships(); 

Attempting to use your package in the Employee class - say to the Department class - complains that type of Employee cannot be assigned to ModelClass. In this case Employee and Department both extend PayrollBaseModel.

Argument of type 'typeof Employee' is not assignable to parameter of type 'ModelClass'. The types of 'QueryBuilder.forClass' are incompatible between these types.

Using the regular relationshipMapping works as expected.

How do I get around this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions