RealmWrapper alternatives and similar libraries
Based on the "Database" category.
Alternatively, view RealmWrapper alternatives based on common mentions on social networks and blogs.
-
MMKV
An efficient, small mobile key-value storage framework developed by WeChat. Works on Android, iOS, macOS, Windows, and POSIX. -
Realm
Realm is a mobile database: a replacement for Core Data & SQLite -
SQLite.swift
A type-safe, Swift-language layer over SQLite3. -
GRDB.swift
A toolkit for SQLite databases, with a focus on application development -
SwiftyUserDefaults
Modern Swift API for NSUserDefaults -
YapDatabase
YapDB is a collection/key/value store with a plugin architecture. It's built atop sqlite, for Swift & objective-c developers. -
ParseAlternatives
GraphQLite is a toolkit to work with GraphQL servers easily. It also provides several other features to make life easier during iOS application development. [Moved to: https://github.com/relatedcode/GraphQLite] -
Couchbase Mobile
Lightweight, embedded, syncable NoSQL database engine for iOS and MacOS apps. -
FCModel
An alternative to Core Data for people who like having direct SQL access. -
UserDefaults
Simple, Strongly Typed UserDefaults for iOS, macOS and tvOS -
CTPersistance
iOS Database Persistence Layer with SQLite, your next Persistence Layer! -
MongoKitten
Native MongoDB driver for Swift, written in Swift -
Unrealm
Unrealm is an extension on RealmCocoa, which enables Swift native types to be saved in Realm. -
Prephirences
Prephirences is a Swift library that provides useful protocols and convenience methods to manage application preferences, configurations and app-state. UserDefaults -
RealmIncrementalStore
Realm-powered Core Data persistent store -
ObjectBox
Swift database - fast, simple and lightweight (iOS, macOS) -
UserDefaultsStore
Why not use UserDefaults to store Codable objects ๐ -
PredicateEditor
A GUI for dynamically creating NSPredicates at runtime to query data in your iOS app. -
Nora
Nora is a Firebase abstraction layer for FirebaseDatabase and FirebaseStorage -
realm-cocoa-converter
A library that provides the ability to import/export Realm files from a variety of data container formats. -
SecureDefaults
Elevate the security of your UserDefaults with this lightweight โจ wrapper that adds an additional layer of AES-256 encryption -
MySQL
A stand-alone Swift wrapper around the MySQL client library, enabling access to MySQL servers. -
PersistenceKit
Store and retrieve Codable objects to various persistence layers, in a couple lines of code! -
PersistentStorageSerializable
Swift library that makes easier to serialize the user's preferences (app's settings) with system User Defaults or Property List file on disk. -
YapDatabaseExtensions
YapDatabase extensions for use with Swift -
TypedDefaults
TypedDefaults is a utility library to type-safely use NSUserDefaults. -
MongoDB
A stand-alone Swift wrapper around the mongo-c client library, enabling access to MongoDB servers. -
PostgreSQL
A stand-alone Swift wrapper around the libpq client library, enabling access to PostgreSQL servers. -
ObjectiveRocks
An Objective-C wrapper for RocksDB - A Persistent Key-Value Store for Flash and RAM Storage. -
Storez
๐พ Safe, statically-typed, store-agnostic key-value storage written in Swift! -
SQLite
A stand-alone Swift wrapper around the SQLite 3 client library. -
FileMaker
A stand-alone Swift wrapper around the FileMaker XML Web publishing interface, enabling access to FileMaker servers.
Appwrite - The Open Source Firebase alternative introduces iOS support
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of RealmWrapper or a related project?
README
RealmWrapper
RealmWrapper is wrapper library for RealmSwift in realm-cocoa
If you use RealmWrapper, you can easily use UI update through Notification and Transaction processing. Also, you do not have to worry about the retain cycle when using self in the Notification block.
At a Glance
If you use RealmSwift, you have to be careful about try statement and thread processing every transaction. However, In RealmManageable which manages one realm file, transaction processing is performed using Realm-only DispatchQueue. RealmProxiable, which owns RealmManageable, can easily add, modify or delete models without having to worry about try statement and thread processing.
User Model
@objcMembers class User: Object { dynamic var id: String? dynamic var name: String?
override static func primaryKey() -> String? {
return "id"
}
}
var user = User() user.id = UUID().uuidString user.name = "Kevin"
> Using RealmSwift
```swift
let realm = try! Realm(configuration: Realm.Configuration(fileURL: URL(fileURLWithPath: RLMRealmPathForFile("user.realm")), schemaVersion: 1, objectTypes: [User.self]))
try! realm.write {
realm.add(user)
}
Using RealmWrapper
UserRealmManager().transaction(writeHandler: { (realm) in realm.add(user) })
UserRealmProxy().append(user)
Threading
By default, you can use the transaction function to process a Realm Transaction in MainThread
UserRealmManager().transaction(writeHandler: { (realm) in realm.add(user) })
It can be implemented by a background thread using DispatchQueue and isSync parameters.
UserRealmManager().transaction(isSync: false, writeHandler: { (realm) in realm.add(user) })
UserRealmManager().transaction(writeQueue: DispatchQueue(label: "background"), isSync: false, writeHandler: { (realm) in
realm.add(user)
})
- You can add completion closure.
swift UserRealmManager().transaction(isSync: false, writeHandler: { (realm) in realm.add(user) }) { (realm, error) in self.tableView.reloadData() }
Getting Started
- Create a
RealmManager
that manages one realm file.
final class UserRealmManager: RealmManageable {
var isUseInMemory: Bool {
return false
}
var schemaVersion: UInt64 {
return 1
}
var fileName: String {
return "user"
}
var objectTypes: [Object.Type]? {
return [User.self]
}
}
- Create a
RealmProxy
that is responsible for the CRUD function to be accessed by the Controller.
struct UserRealmProxy<RealmManager: UserRealmManager>: RealmProxiable {
var users: RealmQuery<User> {
return query(sortProperty: "date", ordering: .ascending)
}
func append(_ user: User) {
rm.transaction(writeHandler: { (realm) in
realm.add(user, update: .all)
})
}
func delete(_ user: User) {
rm.transaction(writeHandler: { (realm) in
realm.delete(user)
})
}
func updateName(id: String, name: String, age: Int) {
guard let user = userFromId(id) else {return}
rm.transaction(writeHandler: { (realm) in
user.name = name
user.age = age
realm.add(user, update: .all)
})
}
func userFromId(_ id: String) -> User? {
return query(filter: "id == '\(id)'").results.first
}
}
var user = User()
user.id = UUID().uuidString
user.name = "Kevin"
UserRealmProxy().append(user)
UserRealmProxy().delete(user)
UserRealmProxy().updateName(id: user.id, name: "Kris")
- If you want to register the notification of the status of the Realm object in the controller, you can register the notification in RealmQuery.
let users: RealmQuery<User> = UserRealmProxy().users
users.setSection(0)
.addInsertNotificationBlock(self) { (self, insertions) in
self.tableView.reloadData()
}
.addModificateNotificationBlock(self) { (self, modifications) in
self.tableView.reloadRows(at: modifications, with: .fade)
}
.addDeleteNotificationBlock(self) { (self, deletions) in
self.tableView.deleteRows(at: deletions, with: .fade)
}
.registerNotification()
Also, since RealmQuery is doing weak handling to prevent the retain cycle, you can use closures without worrying about the retain cycle if you pass only self.
public func addDeleteNotificationBlock<Object: AnyObject>(_ object: Object, block: @escaping (Object, [IndexPath]) -> Void) -> Self {
deleteNotificationBlock = { [weak object] (deletions) in
guard let weakObject = object else {return}
block(weakObject, deletions)
}
return self
}
Usage
RealmManageable Property
Property | Type | Default | Description |
---|---|---|---|
isUseInMemory |
Bool |
required |
Use InMemory Realm |
fileName |
Bool |
required |
Realm File Name |
appGroupIdentifier |
String? |
nil |
Value for Realm file directory for App Extension |
Example
run carthage update
$ carthage update --platform iOS
open RealmWrapper.xcodeproj
$ open RealmWrapper.xcodeproj
run RealmWrapperExample
Installation
CocoaPods (iOS 9+)
platform :ios, '9.0'
use_frameworks!
target '<Your Target Name>' do
pod 'RealmWrapper'
end
Carthage (iOS 9+)
github "k-lpmg/RealmWrapper"
LICENSE
These works are available under the MIT license. See the [LICENSE][license] file for more info.
*Note that all licence references and agreements mentioned in the RealmWrapper README section above
are relevant to that project's source code only.