Is there a way to dynamically set collections name on MongoDB Quarkus?

Viewed 45

In Spring I'm able to use SpEL, and create a collection dynamically for the context of the incoming request, all I've to do is annotate the POJO with @Document and pass the query as a annotation parameter like:

import org.springframework.data.mongodb.core.mapping.Document;

@Document("#{@bean.someMething}Customer")
public class Customer {

    // Fields || Getter || Setter
    
}

But I can't figure a way to easily set this on Quarkus / MongoDB. I do not mind in using quarkus-mongodb-client or mongodb-panache.

I tough that about producing a bean with @RequestContext that would be responsible to create a new MongoDatabase (com.mongodb.client.MongoDatabase) client with some info from the headers.

0 Answers
Related