-
Notifications
You must be signed in to change notification settings - Fork 368
Closed
Description
Consider the following three examples of models.json passed to loopback().boot():
// 1. works
AccessToken: {
options: {
base: 'AccessToken'
},
dataSource: 'db'
},
User: {
options: {
base: 'User',
relations: {
accessTokens: {
model: 'AccessToken',
type: 'hasMany',
foreignKey: 'userId'
}
}
},
dataSource: 'db'
},
// 2. does not work, User.prototype.accesTokens is undefined when called from User.login
User: {
options: {
base: 'User',
relations: {
accessTokens: {
model: 'AccessToken',
type: 'hasMany',
foreignKey: 'userId'
}
}
},
dataSource: 'db'
},
AccessToken: {
options: {
base: 'AccessToken'
},
dataSource: 'db'
},
// 3. lowercase name of `accessToken`, it works
User: {
options: {
base: 'User',
relations: {
accessTokens: {
model: 'accessToken',
type: 'hasMany',
foreignKey: 'userId'
}
}
},
dataSource: 'db'
},
accessToken: {
options: {
base: 'AccessToken'
},
dataSource: 'db'
},
I am not sure what is the exact source of the problem, but this does not feel right. It may be a problem of app.boot, in which case juggler should provide an API that app.boot can use to prevent it.
/to @raymondfeng
Metadata
Metadata
Assignees
Labels
No labels