question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

MultiDatabase .save() Problem

See original GitHub issue

[ ] Regression 
[*] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

Connection config charactersConnection

TypeOrmModule.forRoot app.module.ts

TypeOrmModule.forFeature characters.module.ts

@InjectRepository characters service

work fine with query builder getConnection

but i get error when use .save()

Error: No repository for "CharacterBanned" was found. Looks like this entity is not registered in current "default" connection?

i dont need default connection for that.

Expected behavior

I want use .save() without default connection. .save()

Environment


Nest version: 6.9.0

 
For Tooling issues:
- Node version: 12.13.0
- Platform: Linux

Others:

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
jmcdo29commented, Oct 15, 2021

You’d need to specify you’re using the connection named chat so you can use the Chat entity from ./entitydb2. The minimum reproduction looks related to TypeORM and not to Nest directly. Please look at their repository or slack channel for help.

0reactions
nickyhajalcommented, Oct 15, 2021

For posterity’s sake, I found an answer here: https://github.com/typeorm/typeorm/issues/3205

Which is to do:

EntityOnSecondDatabase.useConnection(getConnection('connection2Name'))
Read more comments on GitHub >

github_iconTop Results From Across the Web

Django model form save (multi database) question
The first example does not work - it doesn't update the instance from the form. Use the second.
Read more >
Multiple databases | Django documentation
See Multi-database support for information about testing with multiple databases. ... Use the using keyword to Model.save() to specify to which database the ......
Read more >
saving multiple students in database at once but problem is it ...
i'm filling students data in database and i want to take the input data of more than one student at the once and...
Read more >
How to Configure Multiple Data Sources in a Spring Boot ...
public DataSource memberDataSource() { ... cardRepository.save() fails (e.g. because of a connection issue) and the _cardTransactionManager_ ...
Read more >
Using Multiple Databases in ASP.NET Core via Entity ...
public void Save() => _repositoryContext. ... We can see that our project works with multiple databases without a single problem.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found