Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 |
Tags
- compose
- Singleton
- 함수형프로그래밍
- 팩토리 메소드
- PrototypePattern
- El
- Functional Programming
- android designsystem
- 안드로이드 디자인시스템
- designPattern
- ㅋㅁ
- factory method
- Kotlin
- ㅓ
- Design Pattern
- builderPattern
- Observer Pattern
- r
- material3
- 추상 팩토리
- F
- 옵저버 패턴
- 싱글톤
- Abstract Factory
- 추상팩토리패턴
- 빌터패턴
- 코틀린
- 프로토타입 패턴
- 디자인패턴 #
- 디자인패턴
Archives
- Today
- Total
오늘도 더 나은 코드를 작성하였습니까?
Realm kotlin Delete 본문
1. realm.write() 또는 realm.writeBlocking()을 사용하여 write 트랜잭션 생성.
2. realm.query()를 사용하여 삭제하려는 객체에 대한 트랜잭션의 mutableRealm 을 쿼리합니다.
객체 유형을 query()에 전달된 Type params로 지정
쿼리를 지정하여 반환된 객체 집합을 필터링.
쿼리가 올바른 개체를 반환하도록 하려면 기본 키 값과 같은 고유 식별 정보로 필터링
3. realmResults.delete()를 사용하여 쿼리에서 반환된 RealmResults 집합을 삭제합니다.
Delete an Object - Kotlin SDK
realm.write {
// fetch the frog by primary key value, passed in as argument number 0
val frog: Frog =
this.query<Frog>("_id == $0", PRIMARY_KEY_VALUE).find().first()
// call delete on the results of a query to delete the object permanently
delete(frog)
}
* write { ... } 트랜잭션 내의 realm에서만 객체를 삭제할 수 있습니다.
Delete Multiple Objects - Kotlin SDK
realm.write {
// fetch 7 frogs of the bullfrog species from the realm
val frogs: RealmResults<Frog> =
this.query<Frog>("species == 'bullfrog' LIMIT(7)").find()
// call delete on the results of a query to delete those objects permanently
delete(frogs)
}
Delete All Objects of a Type - Kotlin SDK
realm.write {
// fetch all frogs from the realm
val frogs: RealmResults<Frog> = this.query<Frog>().find()
// call delete on the results of a query to delete those objects permanently
delete(frogs)
}