loopbackio / loopbackio/loopback-next
Confusing @model() syntax
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- TypeScript
- Sterne
- 5.1k
- Forks
- 1.1k
- Ø Merge
- 2 T. 21 Std.
- Gemergte PRs (30 T.)
- 27
Beschreibung
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:
```ts
@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:
1. Recognize `options` the same way as `settings`. In the example above, `mongodb` settings are not picked by LB4 now. With the proposed change in place, LB4 will set `collection` to `clients` as expected. Alternatively, tell the user setting `options` that they are trying to set an unsupported model-definition property. This can be done at compiler level too.
2. Allow settings to be provided as top-level properties, for example:
```ts
@model({
name: 'client',
strict: false,
mongodb: {
collection: 'clients',
},
})
export class Client extends Entity {
// ...
}
```
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne beim Decorator @model() und verfolge, wie LB4 Modelleinstellungen liest, wobei du dieses Verhalten mit den LB3-Beispielen im Issue vergleichst. Kläre, ob Optionen akzeptiert oder abgelehnt werden sollten und ob Einstellungen auf oberster Ebene unterstützt werden sollten; abgeschlossen ist die Aufgabe, wenn das gewählte Verhalten für die Client-Beispiele implementiert und verifiziert ist.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- typescript
- Bereich
- backend-api-design
- Issue-Typ
- Feature
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 25/100