问题
i am doing some practice with loopback 4, following the tutorial todo-list https://loopback.io/doc/en/lb4/todo-list-tutorial.html
i am trying to query data to gel todo-lists and related todos
GET http://127.0.0.1:3000/todo-lists?filter[include]=todos
i get an error 500 : relations "todos" not defined for the model TodoList
The route GET http://localhost:3000/todo-lists/1/todos works properly, but i'd like to retrieve lists and related todos.
I read many posts and the documentation but i do not understand what is wrong.
Thanks
回答1:
Disclaimer: I am a co-author and one of the current maintainers of LoopBack.
LoopBack 4 does not yet support inclusion of related models when querying the database. You can join the discussion in the following GitHub issues:
- Inclusion of related models #1352
- Include related models in "GET /mymodels" results #1889
Please consider upvoting those issues by pressing the yellow thumbs-up button at the bottom of issue description.
UPDATE - 2020-03-04
These issues have been updated and now you can implement hasMany
relations. Find more info here
来源:https://stackoverflow.com/questions/53162562/loopback-4-hasmany-include-filter-error-500