Coder Social home page Coder Social logo

poissonballon / easyrealm Goto Github PK

View Code? Open in Web Editor NEW
314.0 12.0 29.0 313 KB

EasyRealm is a micro-framework that helps you use Realm.

License: MIT License

Ruby 4.55% Swift 94.01% Shell 0.16% Objective-C 1.28%
realm swift ios framework cocoapods

easyrealm's Introduction

EasyRealm

Version Carthage compatible Platform Build Status Swift 4.2 codecov License

EasyRealm is a micro-framework (less than 200 LOC) that helps you use Realm.

Versions guides

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

Keys Features

EasyRealm import many features as :

  • Deep cascade deleting
  • Deep unmanaged object
  • Get managed object from unmanaged object.
  • Multithread Action (save / edit / delete / query)

Promise

EasyRealm make 4 promises :

  • EasyRealm never transform secretly an unmanaged Object to a managed Object and vice-versa.
  • EasyRealm let you use managed and unmanaged objects identically.
  • EasyRealm never manipulate thread behind your back, you keep full control of your process flow.
  • EasyRealm never handle Error for you.

Examples

Using

  • No inheritance.
  • No protocol.
  • Import Framework
  • Enjoy

Save

To save an object :

let pokemon = Pokemon()
try pokemon.er.save(update: true)
//OR
let managed = try pokemon.er.saved(update: true)

Edit

To edit an object :

let pokemon = Pokemon()

try pokemon.er.edit {
  $0.level = 42
}

Delete

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()

Queries

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")

Helping Variables

  • isManaged :
pokemon.er.isManaged // Return true if realm != nil and return false if realm == nil
  • managed :
pokemon.er.managed // Return the managed version of the object if one exist in Realm Database
  • unmanaged :
pokemon.er.unmanaged // Return an unmanaged version of the object

Installation

EasyRealm is available through CocoaPods. To install it, simply add the following line to your Podfile:

CocoaPods

use_frameworks!
pod "EasyRealm", '~> 3.2.0'

Carthage

github 'PoissonBallon/EasyRealm'

Author

License

EasyRealm is available under the MIT license. See the LICENSE file for more info.

Other

easyrealm's People

Contributors

aureltyson avatar grdsdev avatar kubatruhlar avatar poissonballon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

easyrealm's Issues

Make optional dependancy for Realm cocoapods

Just a thought as it takes too much time to compile Realm sometimes its advisable to keep framework as embedded.

Can we make it as optional in cocoapods ? Just a thought.

Thanks for wonderful library.

Realm 3.0 compatibility

the pod EasyRealm is not compatible with Realm 3.x.

  • RealmSwift (= 3.0.2) required by Podfile.lock
  • RealmSwift (~> 2.4) required by EasyRealm (2.0.1)

pod not installing realm

[!] /bin/bash -c
set -e
sh build.sh cocoapods-setup

xcrun: error: missing DEVELOPER_DIR path: /Users/imac/Downloads/Xcode.app/Contents/Developer

Error for protocol

Need some help. I use Xcode8.3.2

I am getting following error Type 'Object' does not conform to protocol 'EasyRealmCompatible' at

extension Object:EasyRealmCompatible {}

above line in EasyRealm.swift file.

I followed compiler instructions and below is the result

extension Object:EasyRealmCompatible {
    public static var er: EasyRealmStatic<NSObject> {
        
    }

    public var er: EasyRealm<NSObject> {
        get { return EasyRealm(self) }
    }
}

What value should be returned in that EasyRealmStatic getter.

Can you please assist ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.