Skip to content

Confusing @model() syntax #2142

Description

@bajtos

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:

  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:

    @model({
      name: 'client',
      strict: false,
      mongodb: {
        collection: 'clients',
      },
    })
    export class Client extends Entity {
      // ...
    }

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions