MorphiaOrg / MorphiaOrg/morphia

Dynamic collection NamingStrategy

Open
#3,566 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement forward-port
Dominant language
Java
Stars
1.7k
Forks
449
Avg merge
7m
Merged PRs (30d)
10

Description

Duplicate of #2935 for milestone 3.0.0


Is your feature request related to a problem? Please describe.
We use different collections based on the tenant. Previously (v1.x) it was possible to override the getCollectionName method in the Mapper. We would like to be able to use a dynamic NamingStrategy based on the current tenant. However, the current NamingStrategy sets the collectionName in the EntityModel on load and it cannot be changed after that.

Describe the solution you'd like
The NamingStrategy should be called when the getCollectionName() method is called on the EntityModel. Or at least, there should be an option to make it dynamic, so that it's called on getCollectionName().

Describe alternatives you've considered
Can't see any alternative options at the moment.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading EntityModel.getCollectionName() and the NamingStrategy behavior described in the issue, then inspect the duplicate issue #2935 for context. The work is done when collection naming can respond to the current tenant at getCollectionName() time, or when the supported dynamic option and its expected behavior are defined and tested.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, mongodb
Domain
databases
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.