Skip to content

hasMany relations broken with SQL datasources #1909

@gerbus

Description

@gerbus

Description / Steps to reproduce / Feature proposal

I built a simple API modelled very closely after the ToDo and ToDoList example models. However I used a mysql datasource, and I suspect this caused my relations between repositories/models not to work. I had in my ToDoList model a proper @hasMany(() => ToDo decorator. Wired it up in the repository as per documentation instructions. Then I used the API Explorer to do a GET /todolist in the ToDoListController.

Current Behavior

Error: ER_BAD_FIELD_ERROR with 'ToDo' field

I think something is looking to the ToDoList db table looking for the ToDo field. Obviously this doesn't make sense, right? I want the model to represent that, but I have a different table in my database for ToDo.

Expected Behavior

Relation on model works

Related question: Is relational-database discovery available in LB4? Didn't really see a concrete answer in the docs.

I don't have any experience with previous releases of LoopBack.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions