I seem to remember having discussed how to filter ...
# komapper
d
I seem to remember having discussed how to filter the Meta.all() list to only whats in one of the unit objects (not Meta...), I wonder why a specialized all() extension couldn't be generated for each such unit... it could be useful when using connections to multiple dbs in the same service and I need to create the schema for only one of those units in one connection.
t
If you want to retrieve only the metamodels associated with a specific Unit, please use the
EntityMetamodels.list
function.
d
🤔 There's a shortcut for
EntityMetamodels.all()
in
Meta
, maybe there should be one for the units
fun FooUnit.all() = EntityMetamodels.list(this)
so that it shouldn't confuse users, and also it would be more discoverable...
Also, I'm wondering if this feature works between gradle modules... it seems like not.
t
Users should implement the
all
function as a regular function, not as an extension function.
Copy code
object FooUnit {
    fun all(): List<EntityMetamodel<*, *, *>> {
        return EntityMetamodels.list(FooUnit)
    }
}
d
Ok, that's an idea. I guess this is another point that could be mentioned in the docs if that's the way to do it...
I just hope it works in my other module...