EasyRealm is a micro-framework that helps you use Realm.
EasyRealm is a micro-framework (less than 200 LOC) that helps you use Realm.
Swift | Realm | EasyRealm |
---|---|---|
3.0 | >= 2.4 | 2.0.1 |
3.2 / 4.0 | >= 3.1.0 | >= 3.0.0 |
4.2 | >= 3.10 | >= 3.4.0 |
EasyRealm import many features as :
EasyRealm make 4 promises :
To save an object :
let pokemon = Pokemon()
try pokemon.er.save(update: true)
//OR
let managed = try pokemon.er.saved(update: true)
To edit an object :
let pokemon = Pokemon()
try pokemon.er.edit {
$0.level = 42
}
To delete an object :
let pokemon = Pokemon(name: "Pikachu")
try pokemon.er.delete()
//or
try pokemon.er.delete(with: .simple)
//or
try pokemon.er.delete(with: .cascade)
To delete all objects :
try Pokemon.er.deleteAll()
To query all objects of one type :
let pokemons = try Pokemon.er.all()
To query one object by its primaryKey :
let pokemon = Pokemon.er.fromRealm(with: "Pikachu")
pokemon.er.isManaged // Return true if realm != nil and return false if realm == nil
pokemon.er.managed // Return the managed version of the object if one exist in Realm Database
pokemon.er.unmanaged // Return an unmanaged version of the object
EasyRealm is available through CocoaPods. To install
it, simply add the following line to your Podfile:
use_frameworks!
pod "EasyRealm", '~> 3.2.0'
github 'PoissonBallon/EasyRealm'
EasyRealm is available under the MIT license. See the LICENSE file for more info.