-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Support dynamic naming strategy for collection names [DATAMONGO-1863] #2764
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Oliver Drotbohm commented The |
Dan Markhasin commented I believe it does not - as per the example given in DATAMONGO-525, this needs to be dynamic with the ability to extract data from the annotated class itself. @Document(collection= "${info.service_name}_dog")
class Dog
{
private String breed;
}
@Document(collection= "${info.service_name}_cat")
class Cat
{
private String breed;
} |
Dan Markhasin commented Any updates here? Do you need more information? |
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed. |
No, we need a way to specify in |
https://www.examplefiles.net/cs/1040155 This link specifies how we can use dynamic collection names with the environment variables. It worked for me |
I am trying to do something like this, too. My use case entails a configuration that specifies a list of mongo urls, and/or a list of collections for the same URL. If, in my application, I want to perform a kind of query federation over some configured number of collections in one or more mongo instances, I need a way to set up the collection name in the repositories that I configure, especially if they use the same model class, and I don't want to mandate the exact name of the collection. Please let me know if that explanation doesn't make sense, and I will do my best to clear it up. I can get halfway there, and I'll explain what that means. If I disable mongo repository auto-configuration, and create the repository myself, I can construct a I have an example here that demonstrates what I mean. The test writes to embedded mongo, and you have to look in the log output to see the collection name. I don't have a test that checks for the collection that is used when interface methods are invoked, but I can add that soon. So, I think it may be a bug that |
This feature has already worked for quite a while. if you put |
Related to: spring-projects/spring-data-commons#2369. |
resolved via #4683 |
Dan Markhasin opened DATAMONGO-1863 and commented
As described in DATAMONGO-525 (https://jira.spring.io/browse/DATAMONGO-525), we are looking for a way to generate collection names dynamically to support multi-tenancy.
This can be achieved by something as simple as a prefix or by a naming strategy mechanism, simliar to FieldNamingStrategy.
For example, the most simple solution that would work (for us) is to have something like this:
That would generate a collection called animalService_Dog (assuming the service name is animalService).
Any other solution is welcome, but I believe this is a major feature that is currently lacking which is critical for multi-tenancy support
Reference URL: https://jira.spring.io/browse/DATAMONGO-525
1 votes, 3 watchers
The text was updated successfully, but these errors were encountered: