MongoEngine / MongoEngine/mongoengine
dynamically switching db (when dbs are created dynamically, so cannot use aliases)
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 4.3k
- Forks
- 1.2k
- Avg merge
- 4h 41m
- Merged PRs (30d)
- 11
Description
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
admindb & get admin details - connect to
xdb & get list of users - connect to
ccdb & 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?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the document-to-database binding behavior described in the issue and comparing the use case with related issue #1610. Trace how a Document is associated with a database during definition, then establish the scope and tests needed for switching among dynamically named databases within one request; no files or existing tests are identified here.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- mongodb, python
- Domain
- databases
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100