loopbackio / loopbackio/loopback-next

Model level scope: include is not supported in LB4

Open
#9,216 1 comment 0 reactions 0 assignees View on GitHub
bug
Dominant language
TypeScript
Stars
5.1k
Forks
1.1k
Avg merge
2d 21h
Merged PRs (30d)
27

Description

### Describe the bug

In Loopback 3 it was possible to add a scope and include in model annotations on a model class :

`@model({
settings: {
strict: false,
scope: {
include: [
{relation: 'posts'}
]
}
})
`
If you do the same in LB4 an error is thrown that the relation cannot be found as loopback-datasource-juggler does not support LB4 includes.

I have made changes to support model level includes here:

https://github.com/SilexConsulting/loopback-next/tree/support-default-scope-include

I need some help to get this ready to submit a pull request.

### Logs

_No response_

### Additional information

_No response_

### Reproduction

https://github.com/SilexConsulting/loopback-next/tree/support-default-scope-include

Contributor guide

Open the contributing guide

Research direction

Start by reviewing the support-default-scope-include branch and its reproduction in the linked LoopBack 4 repository, focusing on model annotations and loopback-datasource-juggler's handling of includes. Confirm the model-level scope include no longer raises a relation-not-found error and that the reproduced behavior works as expected.

Written by the indexing model from the issue text.

Assessment

Tech stack
nodejs, typescript
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.