Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

before checking relations, check if relations exist inside model #40

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

saadismail
Copy link

If some model (with readonly mixin enabled) does not have relations inside it, the mixin does not work. Here is the stack trace:

/project/node_modules/loopback-ds-readonly-mixin/lib/read-only.js:96
Object.keys(Model.definition.settings.relations).forEach(relationName => {
^

TypeError: Cannot convert undefined or null to object
at Function.keys ()
at EventEmitter.Model.on (/project/node_modules/loopback-ds-readonly-mixin/lib/read-only.js:96:12)
at EventEmitter.emit (events.js:193:13)
at EventEmitter.emit (domain.js:481:20)
at Function.app.model (/project/node_modules/loopback/lib/application.js:162:9)
at /project/node_modules/loopback-boot/lib/executor.js:203:9
at Array.forEach ()
at setupModels (/project/node_modules/loopback-boot/lib/executor.js:199:23)
at execute (/project/node_modules/loopback-boot/lib/executor.js:40:3)
at bootLoopBackApp (/project/node_modules/loopback-boot/index.js:154:3)
at Object. (/project/server/server.js:63:1)
at Module._compile (internal/modules/cjs/loader.js:816:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:827:10)
at Module.load (internal/modules/cjs/loader.js:685:32)
at Function.Module._load (internal/modules/cjs/loader.js:620:12)
at Function.Module.runMain (internal/modules/cjs/loader.js:877:12)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant