What's the recommended way to approach relationships between collections in KMongo?
For the sake of argument, let's assume an object like the following, using kotlinx.serialization:
@Serializable
data class Grouping(
val _id: Id<Grouping> = newId(),
// Relations
val cases: MutableList<@Contextual Id<Case>> = mutableListOf(),
val users: MutableList<@Contextual Id<User>> = mutableListOf(),
// Properties
val createdAt: Instant,
var comment: String,
var name: String,
)
This appears to be what KMongo expects of us. However, I'm not sure what the best approach is here to create an object that contains the matching Case and User documents from the database in a single query. Additionally, I'm not sure how to represent them for storage.
I feel like this should be a common use-case for KMongo, but I can't seem to find anything useful in the docs.