-
Notifications
You must be signed in to change notification settings - Fork 285
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
Define models to be used across multiple databases #727
Comments
Hey @kartsims, you could use the respositoryMode for that. This mode lets you re-use your models. See https://github.com/RobinBuschmann/sequelize-typescript#how-to-enable-repository-mode for details. |
@RobinBuschmann hey awesome work man. |
Hey @kangzj , Hope this helps. |
Still on the topic of the re-use models / repository mode: const myRepo1 = sequelizeConnection1.getRepository(MyModel); Now when I do something like myRepo1.findAll() the data is distinct from myRepo2.findAll() according to the respective databases that are connected to the instances of sequelize above. Now, I was wondering, how to protect against someone writing this code in the repository mode: |
... AAAhhh - clever: |
Still on the topic of the re-use models / repository mode: Can transactions be used with the repository model. So far, did not have much luck. Is there a trick? |
Start the transaction using the sequelizeConnection object rather than the repository instance. |
That's the trick - THANK YOU. |
Sorry if this doesn't belong here but I am having an issue to re-use models across multiple databases. I think this is related to
sequelize-typescript
.When I define my model I am able to add it to a sequelize instance, but when I add it to another instance it fails.
StackOverflow post
The text was updated successfully, but these errors were encountered: