Skip to content

app.model should report unknown options #169

Description

@bajtos

Consider the following code:

var User = app.model('User', {
  options: { base: 'User' },
  relations: {
    accessTokens: {
      model: "AccessToken",
      type: "hasMany",
      foreignKey: "userId"
    }
  },
  dataSource: 'Memory'
});

LoopBack happily ignores relations property and creates a User model without relations. The problem manifests with a mysterious crash of the application much later:

server/node_modules/loopback/lib/models/user.js:160
          user.accessTokens.create({
                            ^
TypeError: Cannot call method 'create' of undefined
    at server/node_modules/loopback/lib/models/user.js:160:29
    at server/node_modules/loopback/lib/models/user.js:224:7
    at server/node_modules/loopback/node_modules/bcryptjs/bcrypt.min.js:40:101
    [cut]

Proposal

app.model and app.dataSource should throw an error when the configuration contains unknown properties.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions