Skip to content

dynamically switching db (when dbs are created dynamically, so cannot use aliases) #1986

Open
@anekix

Description

@anekix

i will try to describe my usecase here:
i am using a multi tenant db model in which each client has their own database( due to very specific business use case). suppose i have to get the users details for a client x that has its own db named x,
these are the steps i need to execute to get the data:

  • connect to admin db & get admin details
  • connect to x db & get list of users
  • connect to cc db & insert some data

all of the above operations are to be executed in a single request to get the required results.

basically i need to map a Document class to multiple dbs which are created dynamically(as clients register) so i cannot hard code this in the document definition.

i guess the default behavior of mongoengine is to bind each Document to a specific database as soon as the code defining the document is executed, but we somehow need to bind documents to a db's dynamically.

other issues that are almost related:
#1610
any specific architectural reason to bind a document to a database at the first execution of document?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions