mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-01-15 21:53:39 +01:00
Updated Home (markdown)
129
Home.md
129
Home.md
@@ -1,108 +1,67 @@
|
||||
# CoreStore
|
||||
[](http://cocoadocs.org/docsets/CoreStore)
|
||||
[](http://cocoadocs.org/docsets/CoreStore)
|
||||
[](http://cocoadocs.org/docsets/CoreStore)
|
||||
[](https://raw.githubusercontent.com/JohnEstropia/CoreStore/master/LICENSE)
|
||||
[](https://github.com/Carthage/Carthage)
|
||||
|
||||
Simple, elegant, and smart Core Data programming with Swift
|
||||
Unleashing the real power of Core Data with the elegance and safety of Swift
|
||||
(Swift, iOS 8+)
|
||||
|
||||
|
||||
|
||||
## What CoreStore does better:
|
||||
- Heavily supports multiple persistent stores per data stack, just the way .xcdatamodeld files are designed to. CoreStore will also manage one data stack by default, but you can create and manage as many as you need.
|
||||
- Ability to plug-in your own logging framework (or any of your favorite 3rd-party logger)
|
||||
- Gets around a limitation with other Core Data wrappers where the entity name should be the same as the `NSManagedObject` subclass name. CoreStore loads entity-to-class mappings from the .xcdatamodeld file, so you are free to name them independently.
|
||||
|
||||
- Heavily supports multiple persistent stores per data stack, just the way *.xcdatamodeld* files are designed to. CoreStore will also manage one data stack by default, but you can create and manage as many as you need.
|
||||
- **New in 1.0.0:** Incremental Migrations! Just tell the data stack the sequence of model versions and CoreStore will automatically use incremental migrations if needed on stores added to that stack.
|
||||
- Ability to plug-in your own logging framework
|
||||
- Gets around a limitation with other Core Data wrappers where the entity name should be the same as the `NSManagedObject` subclass name. CoreStore loads entity-to-class mappings from the managed object model file, so you are free to name them independently.
|
||||
- Provides type-safe, easy to configure observers to replace `NSFetchedResultsController` and KVO
|
||||
- Exposes API not just for fetching, but also for querying aggregates and property values
|
||||
- Makes it hard to fall into common concurrency mistakes. All `NSManagedObjectContext` tasks are encapsulated into safer, higher-level abstractions without sacrificing flexibility and customizability.
|
||||
- Provides convenient API for common use cases.
|
||||
- Clean API designed around Swift’s code elegance and type safety.
|
||||
- Exposes clean and convenient API designed around Swift’s code elegance and type safety.
|
||||
- Documentation! No magic here; all public classes, functions, properties, etc. have detailed Apple Docs. This README also introduces a lot of concepts and explains a lot of CoreStore's behavior.
|
||||
|
||||
**CoreStore's goal is not to expose shorter, magical syntax, but to provide an API that prioritizes readability, consistency, and safety.**
|
||||
**CoreStore's goal is not to expose shorter, magical syntax, but to provide an API that focuses on readability, consistency, and safety.**
|
||||
|
||||
#### TL;DR sample codes
|
||||
|
||||
Quick-setup:
|
||||
```swift
|
||||
CoreStore.addSQLiteStore("MyStore.sqlite")
|
||||
```
|
||||
|
||||
Simple transactions:
|
||||
```swift
|
||||
CoreStore.beginAsynchronous { (transaction) -> Void in
|
||||
let object = transaction.create(Into(MyEntity))
|
||||
object.entityID = 1
|
||||
object.name = "test entity"
|
||||
|
||||
transaction.commit { (result) -> Void in
|
||||
switch result {
|
||||
case .Success(let hasChanges): println("success!")
|
||||
case .Failure(let error): println(error)
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Easy fetching:
|
||||
```swift
|
||||
let objects = CoreStore.fetchAll(From(MyEntity))
|
||||
```
|
||||
```swift
|
||||
let objects = CoreStore.fetchAll(
|
||||
From(MyEntity),
|
||||
Where("entityID", isEqualTo: 1),
|
||||
OrderBy(.Ascending("entityID"), .Descending("name")),
|
||||
Tweak { (fetchRequest) -> Void in
|
||||
fetchRequest.includesPendingChanges = true
|
||||
}
|
||||
)
|
||||
```
|
||||
|
||||
Simple queries:
|
||||
```swift
|
||||
let count = CoreStore.queryValue(
|
||||
From(MyEntity),
|
||||
Select<Int>(.Count("entityID"))
|
||||
)
|
||||
```
|
||||
|
||||
|
||||
## Contents
|
||||
|
||||
- [[TL;DR (a.k.a. sample codes)]]
|
||||
- [[Architecture]]
|
||||
- [[Setting up]]
|
||||
- [[Saving and processing transactions]]
|
||||
- [[Fetching and querying]]
|
||||
- [[Logging and error handling]]
|
||||
- [[Observing changes and notifications]]
|
||||
- CoreStore Tutorials (All of these have demos in the **CoreStoreDemo** app project!)
|
||||
- [[Setting up]]
|
||||
- [[Migrations]]
|
||||
- Incremental migrations
|
||||
- [[Saving and processing transactions]]
|
||||
- Transaction types
|
||||
- Asynchronous transactions
|
||||
- Synchronous transactions
|
||||
- Detached transactions
|
||||
- Creating objects
|
||||
- Updating objects
|
||||
- Deleting objects
|
||||
- [[Fetching and querying]]
|
||||
- `From` clause
|
||||
- Fetching
|
||||
- `Where` clause
|
||||
- `OrderBy` clause
|
||||
- `Tweak` clause
|
||||
- Querying
|
||||
- `Select<T>` clause
|
||||
- `GroupBy` clause
|
||||
- [[Logging and error handling]]
|
||||
- [[Observing changes and notifications]]
|
||||
- Observe a single object
|
||||
- Observe a list of objects
|
||||
- [[Installation]]
|
||||
- [[Changesets]]
|
||||
- Upgrading from v0.2.0 to 1.0.0
|
||||
|
||||
|
||||
# TODO
|
||||
## Roadmap
|
||||
- Data importing utilities for transactions
|
||||
- Migration utilities
|
||||
- Support iCloud stores
|
||||
|
||||
|
||||
# Installation
|
||||
- Requires iOS 8 SDK and above
|
||||
- Swift 1.2
|
||||
|
||||
### Install with Cocoapods
|
||||
```
|
||||
pod 'CoreStore'
|
||||
```
|
||||
This installs CoreStore as a framework. Declare `import CoreStore` in your swift file to use the library.
|
||||
|
||||
### Install as Git Submodule
|
||||
```
|
||||
git submodule add https://github.com/JohnEstropia/CoreStore.git <destination directory>
|
||||
```
|
||||
#### To install as a framework:
|
||||
Drag and drop **CoreStore.xcodeproj** to your project.
|
||||
#### To include directly in your app module:
|
||||
Add all *.swift* files to your project.
|
||||
|
||||
# Contributions
|
||||
While CoreStore's design is pretty solid and the unit test and demo app work well, CoreStore is pretty much still in it's early stage. With more exposure to production code usage and criticisms from the developer community, CoreStore hopes to mature as well.
|
||||
## Contributions
|
||||
While CoreStore's design is pretty solid and the unit test and demo app work well, CoreStore is pretty much still in its early stage. With more exposure to production code usage and criticisms from the developer community, CoreStore hopes to mature as well.
|
||||
Please feel free to report any issues, suggestions, or criticisms!
|
||||
日本語で連絡していただいても構いません!
|
||||
|
||||
|
||||
Reference in New Issue
Block a user