mopidy-musicbox-webclient
mopidy-musicbox-webclient copied to clipboard
Inability to setParameter or ordered by Id field
This is pretty coming scenario to execute queries on Id field
// objectbox: entity
class MyEntity {
var id: Id = 0
//more fields
}
let box: Box<MyEntity> = ...
let query = box.query {
MyEntity.id.isEquals(to: 0)
}.ordered(by: MyEntity.id) --> COMPILATION ERROR here
.build()
query.setParameter(MyEntity.id, 0) --> COMPILATION ERROR here
Some people say IDs should not used in queries at all as they should not represent any application data. What's your use case?
I am storing chat messages in a table and wanted to extract the last message inserted. Doing it via timestamp might be inaccurate as theoretically there could be multiple messages generated in a millisecond. Only way out is to use my own auto increment column which I want to avoid. Also I wanted to sort the messages in the reverse insertion order.
Yes, IDs "happen" to work for that local case. Technically, we don't give guarantees that this will stay like this forever, and, e.g. if you'd use Sync, it would break right away.
Other than that, we'll look into the compilation issue, of course. It will take some time though, as there are other things on our priority queue.