领域,findAllSorted和不同

时间:2016-09-26 17:13:28

标签: android realm kotlin

我有这样的方法:

override fun getStuff(): MutableList<Stuff> = realm.where(Stuff::class.java)
        .findAllSorted("timeStamp", Sort.DESCENDING)
        .distinct("otherId")

其中Stuff的内容有timeStamp个。{ 如果我这样做:

storage.saveStuff(Stuff("a", otherId=1, timeStamp=1))
storage.saveStuff(Stuff("b", otherId=1, timeStamp=2))
storage.saveStuff(Stuff("c", otherId=1, timeStamp=3))
// Other stuff with different otherId

我期待:

storage.getStuff()[0].name == "c"

但事实并非如此。它a 如果我设置Sort.ASCENDING,我仍会获得a。 我做错了什么?

0 个答案:

没有答案