-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Description
Is your feature request related to a problem? Please describe.
Using multiple connections and binding connections to entities.
Describe the solution you'd like
For example:
A request is sent to an API and a middleware would introspect and select which tenant database connection.
I see that the .init the function would preload all the entities. Would that cause any problem to somehow load the entities on-demand based on different database connections?
Ex:
GET /foo (123)
- load database connection for tenant 123.
- When using entities, they would be associated with client 123 connection during the request.
I've found in the docs that it's possible to solve that by using const em = orm.em.fork(); or
app.use((req, res, next) => {
RequestContext.create(orm.em, next);
});
For ref, I think having something like https://vincit.github.io/objection.js/recipes/multitenancy-using-multiple-databases.html in the docs would be very beneficial.
Metadata
Metadata
Assignees
Labels
No labels