境界,findAllSorted和独特
我有这样的一个方法:
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
。 我究竟做错了什么?