From 5136142d83a94c4b5df45919910910087a94fd7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Fri, 18 May 2018 08:49:47 +0200 Subject: [PATCH] Playgrounds documentation --- .../Contents.swift | 22 ++++++++++++------- .../contents.xcplayground | 2 +- Playgrounds/Record.playground/Contents.swift | 8 ++++++- .../Record.playground/contents.xcplayground | 2 +- Playgrounds/Tour.playground/Contents.swift | 8 ++++++- .../Tour.playground/contents.xcplayground | 2 +- .../Contents.swift | 15 ++++++++----- .../contents.xcplayground | 2 +- 8 files changed, 42 insertions(+), 19 deletions(-) diff --git a/Playgrounds/JSONSynchronization.playground/Contents.swift b/Playgrounds/JSONSynchronization.playground/Contents.swift index 039c1ad3a..0a3184746 100644 --- a/Playgrounds/JSONSynchronization.playground/Contents.swift +++ b/Playgrounds/JSONSynchronization.playground/Contents.swift @@ -1,11 +1,17 @@ -// To run this playground, select and build the GRDBOSX scheme. -// -// This sample code shows how to use GRDB to synchronize a database table -// with a JSON payload. We use as few SQL queries as possible: -// -// - Only one SELECT query. -// - One query per insert, delete, and update. -// - Useless UPDATE statements are avoided. +//: To run this playground: +//: +//: - Open GRDB.xcworkspace +//: - Select the GRDBOSX scheme: menu Product > Scheme > GRDBOSX +//: - Build: menu Product > Build +//: - Select the playground in the Playgrounds Group +//: - Run the playground +//: +//: This sample code shows how to use GRDB to synchronize a database table +//: with a JSON payload. We use as few SQL queries as possible: +//: +//: - Only one SELECT query. +//: - One query per insert, delete, and update. +//: - Useless UPDATE statements are avoided. import Foundation import GRDB diff --git a/Playgrounds/JSONSynchronization.playground/contents.xcplayground b/Playgrounds/JSONSynchronization.playground/contents.xcplayground index 16f9952aa..dd3ff35de 100644 --- a/Playgrounds/JSONSynchronization.playground/contents.xcplayground +++ b/Playgrounds/JSONSynchronization.playground/contents.xcplayground @@ -1,4 +1,4 @@ - + \ No newline at end of file diff --git a/Playgrounds/Record.playground/Contents.swift b/Playgrounds/Record.playground/Contents.swift index 258191d82..bb8ad7265 100644 --- a/Playgrounds/Record.playground/Contents.swift +++ b/Playgrounds/Record.playground/Contents.swift @@ -1,4 +1,10 @@ -//: To run this playground, select and build the GRDBOSX scheme. +//: To run this playground: +//: +//: - Open GRDB.xcworkspace +//: - Select the GRDBOSX scheme: menu Product > Scheme > GRDBOSX +//: - Build: menu Product > Build +//: - Select the playground in the Playgrounds Group +//: - Run the playground //: //: Record //: ====== diff --git a/Playgrounds/Record.playground/contents.xcplayground b/Playgrounds/Record.playground/contents.xcplayground index 3de2b51ba..fd676d5b4 100644 --- a/Playgrounds/Record.playground/contents.xcplayground +++ b/Playgrounds/Record.playground/contents.xcplayground @@ -1,4 +1,4 @@ - + \ No newline at end of file diff --git a/Playgrounds/Tour.playground/Contents.swift b/Playgrounds/Tour.playground/Contents.swift index af215f9d5..a87fe0aff 100644 --- a/Playgrounds/Tour.playground/Contents.swift +++ b/Playgrounds/Tour.playground/Contents.swift @@ -1,4 +1,10 @@ -//: To run this playground, select and build the GRDBOSX scheme. +//: To run this playground: +//: +//: - Open GRDB.xcworkspace +//: - Select the GRDBOSX scheme: menu Product > Scheme > GRDBOSX +//: - Build: menu Product > Build +//: - Select the playground in the Playgrounds Group +//: - Run the playground //: //: Tour //: ====== diff --git a/Playgrounds/Tour.playground/contents.xcplayground b/Playgrounds/Tour.playground/contents.xcplayground index 3de2b51ba..fd676d5b4 100644 --- a/Playgrounds/Tour.playground/contents.xcplayground +++ b/Playgrounds/Tour.playground/contents.xcplayground @@ -1,4 +1,4 @@ - + \ No newline at end of file diff --git a/Playgrounds/TransactionObserver.playground/Contents.swift b/Playgrounds/TransactionObserver.playground/Contents.swift index 9a151b925..05553a55e 100644 --- a/Playgrounds/TransactionObserver.playground/Contents.swift +++ b/Playgrounds/TransactionObserver.playground/Contents.swift @@ -1,13 +1,17 @@ -// To run this playground, select and build the GRDBOSX scheme. +//: To run this playground: +//: +//: - Open GRDB.xcworkspace +//: - Select the GRDBOSX scheme: menu Product > Scheme > GRDBOSX +//: - Build: menu Product > Build +//: - Select the playground in the Playgrounds Group +//: - Run the playground import GRDB // Create the databsae -var configuration = Configuration() -configuration.trace = { print($0) } -let dbQueue = DatabaseQueue(configuration: configuration) // Memory database +let dbQueue = DatabaseQueue() // Memory database var migrator = DatabaseMigrator() migrator.registerMigration("createPersons") { db in try db.execute( @@ -80,6 +84,7 @@ try dbQueue.inTransaction { db in print("-- Changes 3") -try dbQueue.inDatabase { db in +try dbQueue.write { db in try db.execute("DELETE FROM persons") + try db.execute("DELETE FROM pets") } diff --git a/Playgrounds/TransactionObserver.playground/contents.xcplayground b/Playgrounds/TransactionObserver.playground/contents.xcplayground index 06828af92..3de2b51ba 100644 --- a/Playgrounds/TransactionObserver.playground/contents.xcplayground +++ b/Playgrounds/TransactionObserver.playground/contents.xcplayground @@ -1,4 +1,4 @@ - + \ No newline at end of file