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

getting error TypeError: Cannot convert undefined or null to object when starting application #29

Open
joshStillerman opened this issue May 8, 2018 · 0 comments

Comments

@joshStillerman
Copy link

joshStillerman commented May 8, 2018

In my model below the properties I have:

"mixins": {
      "ReadOnly" : {
        "entered" : true,
        "dbkey" : true
      }
    }

and when I run the application I get:

$ node .
/Users/jas/loopback/hts/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 (<anonymous>)
    at EventEmitter.Model.on (/Users/jas/loopback/hts/node_modules/loopback-ds-readonly-mixin/lib/read-only.js:96:12)
    at emitOne (events.js:96:13)
    at EventEmitter.emit (events.js:188:7)
    at Function.app.model (/Users/jas/loopback/hts/node_modules/loopback/lib/application.js:162:9)
    at /Users/jas/loopback/hts/node_modules/loopback-boot/lib/executor.js:203:9
    at Array.forEach (native)
    at setupModels (/Users/jas/loopback/hts/node_modules/loopback-boot/lib/executor.js:199:23)
    at execute (/Users/jas/loopback/hts/node_modules/loopback-boot/lib/executor.js:40:3)
    at bootLoopBackApp (/Users/jas/loopback/hts/node_modules/loopback-boot/index.js:154:3)
    at Object.<anonymous> (/Users/jas/loopback/hts/server/server.js:23:1)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)

Is this a bug, or am I just missing something ?
I am using:

    "loopback": "^3.19.0",
    "loopback-boot": "^2.6.5",
    "loopback-component-explorer": "^6.0.0",
    "loopback-connector-mssql": "^2.9.0",
    "loopback-ds-readonly-mixin": "^2.0.4",

I commented out the part about updates via relationship, and it now does not choke. However, when I try to insert a record using a PUT, and leave out readonly fields (because they are provided by the database) I get:

mdsdev4:hts jas$ node .
Web server listening at: http://localhost:3000
Browse your REST API at http://localhost:3000/explorer
Unhandled error for request POST /api/Runs?access_token=heyhey: ValidationError: The `Runs` instance is not valid. Details: `username` can't be blank (value: undefined); `entered` can't be blank (value: undefined); `dbkey` can't be blank (value: undefined).
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

No branches or pull requests

1 participant