Realm-powered Core Data persistent store

Overview

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

You might also like...
Realm Manager for iOS
Realm Manager for iOS

Microservices for RealmSwift. Split realms for easier management and migration

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

CoreDataCloudKitShare - Learn how to use Core Data CloudKit

Sharing Core Data Objects Between iCloud Users Implement the flow to share 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 simple operations using Core Data

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

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

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

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 &

💾 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,

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

Comments
  • Installation section

    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? 😄

    opened by lfarah 0
Owner
Eureka
This is Eureka, Inc. organization.
Eureka
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

Realm 15.7k Jan 1, 2023
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

Yalantis 252 Nov 4, 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

Realm 212 Dec 9, 2022
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

Modo 2.1k Dec 9, 2022
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

Soledad 1.8k Jan 6, 2023
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

Artur  Mkrtchyan 518 Dec 13, 2022
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

Marc Hervera 142 Jul 21, 2022
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

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

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

null 1 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

Underthestars-zhy 20 Jul 4, 2022