From f4def1966be4b0cf37d248783ceb7a1bd8a7d6b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Fri, 29 Jan 2016 06:47:24 +0100 Subject: [PATCH] README.md --- README.md | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 4456e1d27..7944f0460 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,9 @@ extension PointOfInterest { // snip: conformance to database protocols } +let title = SQLColumn("title") +let favorite = SQLColumn("favorite") + try dbQueue.inDatabase { db in // INSERT INTO "pointOfInterests" ... var berlin = PointOfInterest(id: nil, title: "Berlin", favorite: false, coordinate: CLLocationCoordinate2DMake(52.52437, 13.41053)) @@ -69,21 +72,14 @@ try dbQueue.inDatabase { db in berlin.favorite = true try berlin.update(db) - // SELECT * FROM "pointOfInterests" - for poi in PointOfInterest.all().fetch(db) { - print(poi.title, poi.coordinate) - } -} - -let title = SQLColumn("title") -let favorite = SQLColumn("favorite") - -let favorites = dbQueue.inDatabase { db in // SELECT * FROM "pointOfInterests" WHERE "favorite" ORDER BY "title" - PointOfInterest.filter(favorite).order(title).fetchAll(db) + let favorites = PointOfInterest.filter(favorite).order(title).fetchAll(db) + + // Fetch from SQL + let pois = PointOfInterest.fetchAll(db, "SELECT * FROM pointOfInterests") } ``` - + ### Documentation