-
Notifications
You must be signed in to change notification settings - Fork 208
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
My first project fails in any way #256
Comments
@rsa408 This is just an example repo so wrong place to post for help. Try Loopback repo or stackoverflow.com. Please make a git repo to demonstrate the issue as it makes it much easier to quickly spot your issue. |
Hi sample codes ith memoryDB are working fine after changing them to MongoDB everything goes wrong on my machine. I tried to fresh windows npm packages everything but the result was even worse of before. Thanks |
The problem is an inconsistency between your model and the user controllers request body where one says include an id and the other says omit the value. Typically you would not supply an id, so I'd recommend that you set the user model id to be a string(for mongodb) that is not required and generated: true. This would (after running migrate) allow the database to provide a unique id. For your project though to submit an id you need to alter the controller. Change If you have further issues I'd recommend not posting here, but in the aforementioned locations. |
Thanks @dougal83. I've cross-posted your comment in loopbackio/loopback-next#3645. Let's continue the discussion over there (in the right repo). Thanks! |
Hi
I used the following steps to create a project to test it
lb4 test
? Project description: test
? Project root directory: test
? Application class name: TestApplication
? Select features to enable in the project (Press to select, to toggle all, to invert selection)Enable e
slint, Enable prettier, Enable mocha, Enable loopbackBuild, Enable vscode, Enable docker, Enable repositories, Enable services
create .eslintignore
create .eslintrc.js
create .mocharc.json
create .npmrc
create .prettierignore
create .prettierrc
create DEVELOPING.md
create index.ts
create package.json
create README.md
create tsconfig.json
create .vscode\settings.json
create .vscode\tasks.json
create .gitignore
create .dockerignore
create Dockerfile
create index.js
create public\index.html
create src\application.ts
create src\index.ts
create src\migrate.ts
create src\sequence.ts
create src\controllers\index.ts
create src\controllers\ping.controller.ts
create src\controllers\README.md
create src\datasources\README.md
create src\models\README.md
create src\repositories\README.md
create src_tests_\README.md
create src_tests_\acceptance\home-page.acceptance.ts
create src_tests_\acceptance\ping.controller.acceptance.ts
create src_tests_\acceptance\test-helper.ts
Thank you for using core-js ( https://github.com/zloirock/core-js ) for polyfilling JavaScript standard library!
The project needs your help! Please consider supporting of core-js on Open Collective or Patreon:
Also, the author of core-js ( https://github.com/zloirock ) is looking for a good job -)
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN [email protected] No license field.
added 526 packages from 1193 contributors and audited 3840 packages in 489.12s
found 0 vulnerabilities
Application test was created in test.
Next steps:
$ cd test
$ npm start
D:>cd test
D:\test>lb4 datasource
? Datasource name: mdbs
? Select the connector for mdbs: MongoDB (supported by StrongLoop)
? Connection String url to override other settings (eg: mongodb://username:password@hostname:port/database):
? host: 192.168.1.235
? port: 27017
? user:
? password: [hidden]
? database: test
? Feature supported by MongoDB v3.1.0 and above: Yes
create src\datasources\mdbs.datasource.json
create src\datasources\mdbs.datasource.ts
npm WARN [email protected] No license field.
[email protected]
added 6 packages from 11 contributors and audited 4006 packages in 10.84s
found 0 vulnerabilities
update src\datasources\index.ts
Datasource Mdbs was created in src\datasources/
D:\test>lb4 model
? Model class name: test1
? Please select the model base class Entity (A persisted model with an ID)
? Allow additional (free-form) properties? No
Model Test1 will be created in src/models/test1.model.ts
Let's add a property to Test1
Enter an empty property name when done
? Enter the property name: id
? Property type: number
? Is id the ID property? Yes
? Is it required?: Yes
? Default value [leave blank for none]:
Let's add another property to Test1
Enter an empty property name when done
? Enter the property name: text
? Property type: string
? Is it required?: Yes
? Default value [leave blank for none]:
Let's add another property to Test1
Enter an empty property name when done
? Enter the property name: done
? Property type: boolean
? Is it required?: Yes
? Default value [leave blank for none]:
Let's add another property to Test1
Enter an empty property name when done
D:\test>lb4 repository
? Please select the datasource: MdbsDatasource
? Select the model(s) you want to generate a repository Test1
? Please select the repository base class DefaultCrudRepository (Legacy juggler bridge)
identical src\repositories\test1.repository.ts
D:\test>lb4 controller
? Controller class name: test1
Controller Test1 will be created in src/controllers/test1.controller.ts
? What kind of controller would you like to generate? REST Controller with CRUD functions
? What is the name of the model to use with this CRUD repository? Test1
? What is the name of your CRUD repository? Test1Repository
? What is the name of ID property? id
? What is the type of your ID? number
? What is the base HTTP path name of the CRUD operations? /test1s
identical src\controllers\test1.controller.ts
the Try to post fallowing data as the first record for a test:
*```
*{
"id": 10,
"text": "set a",
"done": true
}
422
Undocumented | Error:
Unprocessable Entity
Response body
{
"error": {
"statusCode": 422,
"name": "UnprocessableEntityError",
"message": "The request body is invalid. See error object
details
property for more info.","code": "VALIDATION_FAILED",
"details": [
{
"path": "",
"code": "not",
"message": "should NOT be valid",
"info": {}
}
]
}
}
}
The text was updated successfully, but these errors were encountered: