我想从 Realm 中删除所有与用户 ID 相等的消息对象。
RealmQuery<Message> rowQuery = realm.where(Message.class).equalTo(Message.USER_ID, userId);
realm.beginTransaction();
//TODO : here I want to remove all messages where userId is equal to "9789273498708475"
realm.commitTransaction();
.clear()
方法中加入注释说明.deleteAllFromRealm()
是现在应该使用的正确方法会很好。 - Ed LeeRealmList<Message>
。如果我们以某种方式删除了整个Message
行,那么它是否也会在该模型上被删除?(请参阅 https://stackoverflow.com/questions/49029813/realm-the-size-of-filled-realmlist-in-realmobject-is-zero) - Dr.jacky