Association between tables in different DBs ignored
See original GitHub issueI have two tables. They belong to different databases.
export default db1.define(`hero`, {
teamId: {
type: Sequelize.INTEGER
....
},
name; {
type: Sequelize.STRING
}
....
}
export default db2.define(`team`, {
id: {
type: Sequelize.INTEGER
},
name; {
type: Sequelize.STRING
}
....
}
Then in another file, I associate hero
with team
like this in another file.
import Hero
import Team
Hero.hasOne(Team, {foreignKey: 'teamId'})
Now it is telling me that "ER_NO_SUCH_TABLE: Table 'db1.team' doesn't exist"
.
It seems to be ignoring my db specification. Is this normal? And how should I counteract this?
It should be trying to associate db1.hero
with db2.team
.
Thanks.
Dialect: mysql __Database version: 5.6.31 __Sequelize version: ^3.14.2
Issue Analytics
- State:
- Created 7 years ago
- Reactions:2
- Comments:26 (10 by maintainers)
Top Results From Across the Web
Relationships between tables from different databases not ...
HELP - Relationships are not working I am pulling data from one databse and trying to join that with a table from another...
Read more >why there is databases with no RELATIONSHIP between their ...
I didn't ever read about ignoring RELATIONSHIPS in databases with tables that have logically relate to each other. My question is, Not defining ......
Read more >Relationships between tables in a Data Model
A relationship is a connection between two tables of data, based on one column in each. A workbook can store each piece of...
Read more >Eight Common Database Design Bad Practices - Toptal
Redundant fields and tables are a nightmare for developers, since they require business logic to keep many version of the same information up...
Read more >Relational vs Non-Relational Databases - Pluralsight
The connection between the primary and foreign key then creates the “relationship” between records contained across multiple tables. This image ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
¿There is a solution for this issue? I have this problem I need to create an association between tables in two different databases on MySQL. if I use table1.hasOne(table2…) sequelize assumes both in the same database when it creates the SQL statement.
This is a duplicate of #2089 as said above.