Sorry I took a while to come back to this.
From the readme doc, this is the API to read some values from the database.
val merchantStore = sqkon.keyValueStore<Merchant>("merchant")
select(where = Merchant::name like "Chi%")
val flow: Flow<List<Merchant>> = merchantStore.select(where = Merchant::name like "Chi%")
But in a typical usage of this storage API you will have several stores. Lets say:
val merchantStore = sqkon.keyValueStore<Merchant>("merchant")
val employeeStore = sqkon.keyValueStore<Employee>("employee")
// Then accidentally
val flow: Flow<List<Merchant>> = merchantStore.select(where = Employee::name like "Chi%")
Q1: Do I get a compiler warning or some static code analysis warning at compilation time? - Indicating the field
Employee::name
does not belong to Merchant?
Q2: What will happen at runtime, exception or null is returned?
Then I was thinking of an API that reifies the type.
val flow: Flow<List<Merchant>> = merchantStore.select<Merchant>(where = Employee::name like "Chi%")
Notice the
merchantStore.select<Merchant>(...)
. I was thinking that perhaps passing the type could be used internally in select() to make sure the fields match. However, I am thinking now, that this is possible at runtime and would be inefficient.
Definitely this is something that has to be done at compilation time perhaps as a compiler or KSP plugin.