GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - bastos/QueryKit: A simple CoreData query language for Swift.

BranchesTags
Open more actions menu
 
 

Latest commit

 

History

21 Commits
21 Commits

Folders and files

NameName
Last commit message
Last commit date
QueryKit.xcodeproj
QueryKit.xcodeproj
 
 
QueryKit
QueryKit
 
 
QueryKitTests
QueryKitTests
 
 
.travis.yml
.travis.yml
 
 
LICENSE
LICENSE
 
 
QueryKit.podspec
QueryKit.podspec
 
 
README.md
README.md
 
 

Repository files navigation

QueryKit

Build Status

QueryKit, a simple CoreData query language for Swift.

Usage

Person.queryset(context).filter(Person.name == "Kyle").delete()

Querying

To retrieve objects from CoreData with QueryKit, you can construct a QuerySet for your model in a managed object context.

A queryset is an immutable object, any operation will return a new queryset instead of modifying the queryset.

var queryset = Person.queryset(context)

Filtering

You can filter a queryset using the filter and exclude methods, which accept a predicate and return a new queryset.

queryset.filter(NSPredicate(format:"name == %@", "Kyle"))
queryset.filter(Person.name == "Kyle")
queryset.exclude(Person.age < 21)

Ordering

You can order a queryset's results by using the orderBy method which accepts a collection of sort descriptors:

queryset.orderBy(NSSortDescriptor(key: "name", ascending: true))
queryset.orderBy(Person.name.ascending)
queryset.orderBy([Person.name.ascending, Person.age.descending])

Slicing

You can use slicing to limit a queryset to a range. For example, to get the first 5 items:

queryset[0..5]

Fetching

Single object

var kyle = queryset.filter(Person.name == "Kyle").get()

Object at index

var orta = queryset[3]

Count

println("There are \(queryset.count() - 1) more Kyle's.")

Iteration

for person in queryset {
    println(person.name)
}

Conversion to an array

queryset.array()

Deleting

This method immediately deletes the objects in your queryset and returns a count and an error if the operation failed.

queryset.delete()

Predicate extensions

We've extended NSPredicate to add support for the !, && and || operators for joining predicates together.

NSPredicate(format:"name == Kyle") || NSPredicate(format:"name == Katie")
NSPredicate(format:"age >= 21") && !NSPredicate(format:"name == Kyle")
Person.name == "Kyle" || Person.name == "Katie"
Person.age >= 21 || Person.name != "Kyle"

License

QueryKit is released under the BSD license. See LICENSE.

About

A simple CoreData query language for Swift.

Resources

Readme
BSD-2-Clause license
Activity

Stars

0 stars

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.