loopbackio / loopbackio/loopback-next
Confusing @model() syntax
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 5.1k
- Forks
- 1.1k
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 27
Description
In LB3, users could specify model settings at two levels: as a root property or inside options property.
See https://stackoverflow.com/q/53307168/69868 for an example of LB3 syntax applied in an LB4 project:
@model({
settings: {strict: false},
name: 'client',
plural: 'clients',
options: {
mongodb: {
collection: 'clients',
},
},
})
export class Client extends Entity {
// ...
}
I am proposing to make two changes in LB4 to help users coming from LB3:
-
Recognize
optionsthe same way assettings. In the example above,mongodbsettings are not picked by LB4 now. With the proposed change in place, LB4 will setcollectiontoclientsas expected. Alternatively, tell the user settingoptionsthat they are trying to set an unsupported model-definition property. This can be done at compiler level too. -
Allow settings to be provided as top-level properties, for example:
@model({ name: 'client', strict: false, mongodb: { collection: 'clients', }, }) export class Client extends Entity { // ... }
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the @model() decorator and trace how LB4 reads model settings, comparing that behavior with the LB3 examples in the issue. Resolve whether options should be accepted or rejected and whether top-level settings should be supported; done means the chosen behavior is implemented and verified for the Client examples.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- backend-api-design
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100