- 작성시간 : 2014/09/21 17:03
- 퍼머링크 : always19.egloos.com/3006301
- 덧글수 : 0
ios에서 realm이라는 persistent store가 나왔다.
엄청 빠르다고 자랑하고 있다.
ORM까지 포함돼 있는 것이 장점.
처음에 swift project에 추가하는게 잘 되지 않았다.
SwiftyJSON에서 이미 top-level(?) extension을 쓰고 있기 때문에, 이것이랑 충돌 안나는 사용법으로 써야 한다.
시키는 대로 해도 잘 안됐었는데, library를 한 번 없애고 다시 추가하니까 되는 것 같다.
한참 헤맸다.
그래도 swift library project를 추가하는 게 가능하다는 것을 처음 알았다 ㅎㅎ
xcode6 beta4 정도부터 가능해진건가?
아직 간단한 sample도 안만들었는데, 단점이 많이 보이네.
64bit longLong value를 저장할 수 없는 것이 치명적이 단점.
id를 string으로 저장해야 되네.
id를 primary key로 지정해둘 수는 있는데,
다른 columns나 column set을 unique하게 만들 수가 없다.
bulk update가 불편하고 느릴 수 있겠다. transaction 걸고, code로 해야 되네.
싹 지우고 update하고 싶어도 DELETE table도 한 번에 못한다는 것도 단점.
Excellent
- "fast"そうだ。
Good
- ORM, app
- swift support
- NSPredicate
OK
Bad
- primaryKey 以外の unique constraintを入れるのができない。
- bulk updateが遅いかも。
- Insert-or-update — If your dataset has a unique identifier such as a primary key (or set of unicity conditions), you can use it to easily code insert-or-update logic: when receiving a response from the API, you can check if each record already exists by querying the Realm for it. If it does exist locally, update with the latest details from the response, if not, insert it into the Realm.
- これがBest practice? だそうだけど、信じられない。
- override class func primaryKey() -> String! はある。
- No DELETE table
- defaultRealm.deleteObjects(...Model.allObjects)
Terrible
- No 64bit longLongValue http://realm.io/docs/cocoa/0.85.0/api/Classes/RLMObject.html
Overview
In Realm you define your model classes by subclassing RLMObject and adding properties to be persisted. You then instantiate and use your custom subclasses instead of using the RLMObject class directly.
// Dog.h @interface Dog : RLMObject @property NSString *name; @property BOOL adopted; @end // Dog.m @implementation Dog @end //none neededSupported property types
NSStringNSInteger,CGFloat,int,long,float, anddoubleBOOLorboolNSDateNSData- RLMObject subclasses, so you can have many-to-one relationships.
RLMArray<X>, where X is an RLMObject subclass, so you can have many-to-many relationships.



덧글