Giter Site home page Giter Site logo

breeze's Introduction

Breeze

Lightweight CoreData manager written in Swift

Breeze takes a lot of cues from both MagicalRecord and Nimble

  • Lightweight and simple to setup and use
  • 1 row of code to find first/any object in database
  • iCloud support
  • Simple architecture using only a main and a background context.

Install

Install using CocoaPods

pod "Breeze"

Then import <Breeze.h/Breeze.h> into your .pch file

Right now Swift does not work with CocoaPods, so download the files and include them manually... :-(

Setup

First, setup either a local or a iCloud store

if BreezeStore.iCloudAvailable() {
    BreezeStore.setupiCloudStoreWithContentNameKey("iCloudTestContentName", localStoreName: "iCloudTest", transactionLogs: "iCloud_transactions_logs")
} else {
    BreezeStore.setupStoreWithName("Test", type: NSSQLiteStoreType, options: [NSMigratePersistentStoresAutomaticallyOption: true, NSInferMappingModelAutomaticallyOption: true])
}

Saving

BreezeStore.saveInBackground { contextType -> Void in
    let car = Car.createInContextOfType(contextType)
    car.color = UIColor.blueColor()
}

Finding

Find single objects by attribute

let car = Car.findFirst(attribute: "myAttribute", value: 1, contextType: BreezeContextType.Main)

or by predicate

let car = Car.findFirst(predicate: myPredicate, sortedBy: "anotherAttribute", ascending: false, contextType: BreezeContextType.Main)

Likewise, find all objects by attribute

let cars = Car.findAll(attribute: "myAttribute", value: 1, contextType: BreezeContextType.Main)

or by predicate

let cars = Car.findAll(predicate: myPredicate, sortedBy: "anotherAttribute", ascending: false, contextType: BreezeContextType.Main)

Counting

If you just need to count the objects of a query, use the countAll function

let carCount = Car.countAll(predicate: myPredicate, sortedBy: "anotherAttribute", ascending: false, contextType: BreezeContextType.Main)

License

Breeze is available under the MIT license. See the file LICENSE.

breeze's People

Contributors

andrelind avatar readmecritic avatar rizal72 avatar

Watchers

James Cloos avatar  avatar

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.