gutsy | ASGI server for Python | Websocket library
kandi X-RAY | gutsy Summary
kandi X-RAY | gutsy Summary
An experimental ASGI server for Python 3.7+.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of gutsy
gutsy Key Features
gutsy Examples and Code Snippets
Community Discussions
Trending Discussions on gutsy
QUESTION
I have many to many relationship between User and Routes, and User and Books. I created some seeder data to populate my database. And I was able to find User and include ROUTEs and BOOKs. IF I do not seed the database, everything still work. I just manually POST all the relationships and associations with POSTMAN. I can find User by ID and it includes its ROUTEs and BOOKs. The problem comes in when I try to do both. After seeding the data, I cannot seem to set any associations afterward using POSTMAN.
I dont really know which part of the code should I be putting here since I have no idea what is causing the problem. But here is the repo(branch test): https://github.com/leogoesger/gutsy-api
This is what i get just doing migration without seeding:
js
{
"id": 1,
"role": "ADMIN",
"firstName": "Leo",
"middleName": "",
"lastName": "Qiu",
"email": "leoq91@gmail.commm",
"password": "$2a$10$a/Rv18tGFr1MgxcJkrd0aewo9lJXUxbNJMiq4.cIuWUOq0fSp.Uju",
"address1": "319 I st",
"address2": "",
"city": "Davis",
"zip": "95616",
"isVerified": false,
"createdAt": "2017-11-22T02:33:23.425Z",
"updatedAt": "2017-11-22T02:33:23.425Z",
"routes": [
{
"id": 1,
"name": "The Cave Route",
"description": "Ice cave",
"grade": "V10",
"category": "Boulder",
"open": true,
"createdAt": "2017-11-22T02:38:32.024Z",
"updatedAt": "2017-11-22T02:38:32.024Z",
"areaId": 1,
"UserRoute": {
"id": 1,
"userId": 1,
"routeId": 1,
"createdAt": "2017-11-22T02:38:34.316Z",
"updatedAt": "2017-11-22T02:38:34.316Z"
}
}
],
"books": [
{
"id": 1,
"title": "The good, the great and the awesome",
"description": "A cool book about High Sierra!",
"price": "39.99",
"createdAt": "2017-11-22T02:38:29.313Z",
"updatedAt": "2017-11-22T02:38:29.313Z",
"UserBook": {
"id": 1,
"userId": 1,
"bookId": 1,
"createdAt": "2017-11-22T02:38:36.970Z",
"updatedAt": "2017-11-22T02:38:36.970Z"
}
}
]
}
This is what i get just doing migration with seeding. I can see all the associations in the DB.
js
{
"id": 3,
"role": "ADMIN",
"firstName": "Leo",
"middleName": "",
"lastName": "Qiu",
"email": "leoq91@gmail.commm",
"password": "$2a$10$a/Rv18tGFr1MgxcJkrd0aewo9lJXUxbNJMiq4.cIuWUOq0fSp.Uju",
"address1": "319 I st",
"address2": "",
"city": "Davis",
"zip": "95616",
"isVerified": false,
"createdAt": "2017-11-22T02:33:23.425Z",
"updatedAt": "2017-11-22T02:33:23.425Z",
"routes": [ ],
"books": [ ]
}
Well, I want to get my routes and books data associated to User.
What is actually happening?Nothing is coming back
Output, either JSON or SQL
Dialect: postgres 9.6 __Dialect version: XXX Database version: XXX Sequelize version: XXX Tested with master branch: No
Note : Your issue may be ignored by maintainers if it's not tested against master
branch OR does not follow issue template.
ANSWER
Answered 2017-Nov-22 at 04:18Embrassing!
User.belongsToMany(Project, { as: 'Tasks', through: 'worker_tasks', foreignKey: 'userId' })
Project.belongsToMany(User, { as: 'Workers', through: 'worker_tasks', foreignKey: 'projectId' })
Above is how I suppose to set it up
but i did the following:
User.belongsToMany(Project, { as: 'Tasks', through: 'worker_tasks', foreignKey: 'projectId' })
Project.belongsToMany(User, { as: 'Workers', through: 'worker_tasks', foreignKey: 'userId' })
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install gutsy
You can use gutsy like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page