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.

Connecting to the database synchronously

See original GitHub issue

Is it possible to connect to the database synchronously? For my app, there’s no issue with the current asynchronous method, but I’m running into weird timing issues. I wouldn’t want my app to run at all if the database is not ready, because it wouldn’t make sense. Also, I would like to create a connection once and reuse it in separate places, but this doesn’t seem to be officially supported.

The error message I get with the tests RepositoryNotFoundError: No repository for "Material" was found. Looks like this entity is not registered in current "default" connection?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

10reactions
pleerockcommented, Jul 27, 2017

Is it possible to connect to the database synchronously?

no, it does not make sense

I’m running into weird timing issues

you simply need to figure out your problems and get know how to properly handle all async processes in node apps

Also, I would like to create a connection once and reuse it in separate places, but this doesn’t seem to be officially supported.

you can create a QueryRunner which holds a single database connection and use it across the app. Use connection.createQueryRunner() for this purpose. And remember to release it once you done with it (using queryRunner.release method)

RepositoryNotFoundError: No repository for “Material” was found. Looks like this entity is not registered in current “default” connection?

did you register your entity in “entity” section of connection config?

0reactions
BrainMaestrocommented, Jul 31, 2017

@NoNameProvided looks like it’s related. Thanks

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why is Go connecting to a database synchronously?
I do find it weird that code is mostly synchronous - even things like connecting and communicating with the database, e.g.
Read more >
Using synchronous and asynchronous database operations
A single database connection can't execute some operations or statements synchronously and others asynchronously. You specify whether a SQLConnection ...
Read more >
Data synchronization in SQL Server Always On Availability ...
This article describes the data synchronization process on SQL Server Always On Availability Groups in both Synchronous, and Asynchronous ...
Read more >
Synchronous and asynchronous query execution
Queries can be executed against the database synchronously or asynchronously. The correct execution paradigm to use depends on the application.
Read more >
How to setup a synchronously Mirrored Database
Setup in Synchronous Mode · 1. On the machine that is to be used as Principal, connect via Microsoft SQL Server Management Studio...
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