こんな感じでselectした結果をRealmListでほしかったのだけど
val results = realm.where(Game::class.java).findAll().sort(Game::startDate.toString())
帰ってくる結果はRealmresults。
ほしいのはそれじゃないんだよ〜。ということで、RealmListでオブジェクトが欲しかったのでその変換方法についてご紹介。
答えはイカにあった。
I have a RealmResults object. I want to convert it to RealmList object. any suggestions? How to convert RealmResults object to RealmList? - Stack Overflow |
RealmList results = new RealmList(); results.addAll(realmResultList.subList(0, realmResultList.size()));
これはJavaで書かれているが、kotlinならこんな感じ。
val results = RealmList() results.addAll(realmResultList.subList(0, realmResultList.size))
別途RealmListを定義してaddAllしちゃいましょう!
RealmListで取りに行くと早いって噂もあるのでRealmListでモデルは定義しておいたほうがいい気がしますね。
cf: Realmでの1対多の関係の記述について
こんにちは。virapture…
View Comments
Your point of view caught my eye and was very interesting. Thanks. I have a question for you. https://www.binance.info/fr/join?ref=UM6SMJM3
I don't think the title of your article matches the content lol. Just kidding, mainly because I had some doubts after reading the article.
Thanks for sharing. I read many of your blog posts, cool, your blog is very good. https://accounts.binance.com/lv/register-person?ref=B4EPR6J0
Thank you for your sharing. I am worried that I lack creative ideas. It is your article that makes me full of hope. Thank you. But, I have a question, can you help me?