Realm-powered Core Data persistent store

Last update: Jun 24, 2022

RealmIncrementalStore

Realm-powered Core Data persistent store

Wait, what?

I like Realm. Realm's memory-mapped DB blows other databases out of the water. It's fast and memory efficient.

I also like Core Data. (disclaimer: I'm the author of CoreStore.) It's a very stable ORM framework and it works on top of any persistent store.

Here's the kicker: Core Data is stuck with SQLite until a better lightweight DB comes along, and Realm's database engine is phenomenal but its Cocoa framework is still lacking some features.

Fortunately, Core Data's NSIncrementalStore interface lets us use the best of both worlds. RealmIncrementalStore is an NSIncrementalStore subclass that dynamically creates Realm schema using your Core Data models.

Here's an NSFetchedResultsController running on Realm back-end (right: Realm Browser):

Demo App and Realm Browser

(Check the RealmIncrementalStoreDemo to see how it works)

That said, this project is still in its prototype stages and is more of a proof-of-concept than a working product. Use at your own risk!

How to setup

Just include RealmIncrementalStore in your project and everything else is good old Core Data code. You just have to specify RealmIncrementalStore.storeType when calling addPersistentStoreWithType() on the NSPersistentStoreCoordinator:

let coordinator = NSPersistentStoreCoordinator(...)
do {
    
    try coordinator.addPersistentStoreWithType(
        RealmIncrementalStore.storeType, // here
        configuration: nil,
        URL: url,
        options: nil
    )
}
catch {
    
    // ...
}

Features

Right now, most of Core Data's functionality works:

  • Inserting / Updating / Deleting
  • Fetching
  • NSFetchedResultsControllers
  • Relationships
  • Basically most of what NSIncrementalStores were designed to work in

Missing bits / To Do

(Pull Requests are welcome!)

  • Relationships (in progress, halfway there) Done
  • Migrations
  • Fine-grained handling of NSFetchRequests
  • Optimizations (still waiting for the Realm folks to open-source the realm-core)
  • Try to implement NSPredicates that are not yet supported in Realm (?)
  • Benchmark!

Author

https://github.com/JohnEstropia

License

RealmIncrementalStore is released under an MIT license. See the LICENSE file for more information

GitHub

https://github.com/eure/RealmIncrementalStore
You might also like...

Realm Manager for iOS

Realm Manager for iOS

Microservices for RealmSwift. Split realms for easier management and migration

Jul 15, 2022

An alternative to Core Data for people who like having direct SQL access.

FCModel 2 An alternative to Core Data for people who like having direct SQL access. By Marco Arment. See the LICENSE file for license info (it's the M

Aug 6, 2022

CoreDataCloudKitShare - Learn how to use Core Data CloudKit

Sharing Core Data Objects Between iCloud Users Implement the flow to share data

Feb 10, 2022

BowTies - The main purpose of this application is to show how you can perform simple operations using Core Data

BowTies - The main purpose of this application is to show how you can perform simple operations using Core Data

BowTies The main purpose of this application is to show how you can perform simp

Jan 31, 2022

Store and retrieve Codable objects to various persistence layers, in a couple lines of code!

Store and retrieve Codable objects to various persistence layers, in a couple lines of code!

tl;dr You love Swift's Codable protocol and use it everywhere, who doesn't! Here is an easy and very light way to store and retrieve Codable objects t

Aug 1, 2022

StorageManager - FileManager framework that handels Store, fetch, delete and update files in local storage

StorageManager - FileManager framework that handels Store, fetch, delete and update files in local storage

StorageManager - FileManager framework that handels Store, fetch, delete and update files in local storage. Requirements iOS 8.0+ / macOS 10.10+ / tvOS

Jun 21, 2022

YapDB is a collection/key/value store with a plugin architecture. It's built atop sqlite, for Swift & objective-c developers.

YapDB is a collection/key/value store with a plugin architecture. It's built atop sqlite, for Swift & objective-c developers.

YapDatabase is a collection/key/value store and so much more. It's built atop sqlite, for Swift & Objective-C developers, targeting macOS, iOS, tvOS &

Jul 26, 2022

💾 Safe, statically-typed, store-agnostic key-value storage written in Swift!

Storez 💾 Safe, statically-typed, store-agnostic key-value storage Highlights Fully Customizable: Customize the persistence store, the KeyType class,

May 17, 2022

Key-Value store for Swift backed by LevelDB

SwiftStore Key/Value store for Swift backed by LevelDB. Usage Create instances of store import SwiftStore // Create a store. let store = SwiftStore(s

Apr 15, 2022
Comments
  • 1. Installation section

    Hey, your library is really interesting.

    The only problem I found was the README.md, which lacks an Installation Section I created this iOS Open source Readme Template so you can take a look on how to easily create an Installation Section If you want, I can help you to organize the lib.

    What are your thoughts? 😄

    Reviewed by lfarah at 2016-07-17 01:34
Realm is a mobile database: a replacement for Core Data & SQLite

Realm is a mobile database that runs directly inside phones, tablets or wearables. This repository holds the source code for the iOS, macOS, tvOS & wa

Aug 6, 2022
A library that provides the ability to import/export Realm files from a variety of data container formats.

Realm Converter Realm Converter is an open source software utility framework to make it easier to get data both in and out of Realm. It has been built

Jul 20, 2022
CloudKit, Apple’s remote data storage service, provides a possibility to store app data using users’ iCloud accounts as a back-end storage service.
CloudKit, Apple’s remote data storage service, provides a possibility to store app data using users’ iCloud accounts as a back-end storage service.

CloudKit, Apple’s remote data storage service, provides a possibility to store app data using users’ iCloud accounts as a back-end storage service. He

Jul 18, 2022
CoreData/Realm sweet wrapper written in Swift
CoreData/Realm sweet wrapper written in Swift

What is SugarRecord? SugarRecord is a persistence wrapper designed to make working with persistence solutions like CoreData in a much easier way. Than

Jul 29, 2022
Sync Realm Database with CloudKit
Sync Realm Database with CloudKit

IceCream helps you sync Realm Database with CloudKit. It works like magic! Features Realm Database Off-line First Thread Safety Reactive Programming O

Aug 3, 2022
Unrealm is an extension on RealmCocoa, which enables Swift native types to be saved in Realm.
Unrealm is an extension on RealmCocoa, which enables Swift native types to be saved in Realm.

Unrealm enables you to easily store Swift native Classes, Structs and Enums into Realm . Stop inheriting from Object! Go for Protocol-Oriented program

Aug 3, 2022
Realm GeoQueries made easy
Realm GeoQueries made easy

RealmGeoQueries simplifies spatial queries with Realm Cocoa. In the absence of and official functions, this library provide the possibility to do prox

Jul 21, 2022
A simple order manager, created in order to try Realm database
A simple order manager, created in order to try Realm database

Overview A simple order manager, created in order to get acquainted with the features and limitations of the local Realm database. The project is writ

Oct 14, 2021
Creating a Todo app using Realm and SwiftUI
Creating a Todo app using Realm and SwiftUI

Realmで作るTodoアプリ note記事「【SwiftUI】Realmを使ってTodoアプリを作る」のソースです。

Jul 20, 2022
MagicData - A replacement of SQlite, CoreData or Realm.

MagicData A replacement of SQlite, CoreData or Realm. It is very easy to use and is a light version. Guides MagicData We use MagicData manage all the

Jul 4, 2022