Skip to content
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

"No such connection with name \"default\" exists" or "Connection Already Exists" #357

Open
alfredopatnella opened this issue Aug 29, 2023 · 2 comments

Comments

@alfredopatnella
Copy link

Hi. Thanks for a wonderful library.

I am having trouble with LAMBDA implementation as if I create the connection it works fine the first time, but the next time, since the lambda is already running it yells about the connection already existing.

Is there a way to determine if the connection is already established like in typeORM with getConnectionManager().connections.find('default'); or something similar?

Or is there another smart way to handle this?

@lausek
Copy link
Contributor

lausek commented Sep 5, 2023

There is getConnection() for retrieving the default connection. It throws if the connection does not exist yet.

For named connections, you would have to retrieve the ConnectionManager from the Container and then do .get("something").

const connectionManager = Container.get(ConnectionManager)

try {
  return connectionManager.get(name)
} catch(e) {
  return createConnection({ ... });
}

@amang95
Copy link

amang95 commented Oct 25, 2023

I see the No such connection with name error post moving to Node v18. Is there some sort of compatibility issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants