From 754c8fa0cddc7bcc525d28d48b43a3c4461852e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Mon, 5 Oct 2015 20:12:41 +0200 Subject: [PATCH] README.md --- README.md | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b104f4751..445aa5bca 100644 --- a/README.md +++ b/README.md @@ -215,21 +215,26 @@ To create tables, we recommend using [migrations](#migrations). ## Fetch Queries -You can fetch **Rows**, **Values**, and **Records**: +You can fetch **[Rows](#row-queries)**, **[Values](#value-queries)**, and **[RowConvertible](#rowconvertible-protocol) types**, including **[Records](#records)**. ```swift dbQueue.inDatabase { db in + // Rows Row.fetch(db, "SELECT ...", ...) // DatabaseSequence Row.fetchAll(db, "SELECT ...", ...) // [Row] Row.fetchOne(db, "SELECT ...", ...) // Row? + // Values String.fetch(db, "SELECT ...", ...) // DatabaseSequence String.fetchAll(db, "SELECT ...", ...) // [String] String.fetchOne(db, "SELECT ...", ...) // String? + // RowConvertible & Records Person.fetch(db, "SELECT ...", ...) // DatabaseSequence Person.fetchAll(db, "SELECT ...", ...) // [Person] Person.fetchOne(db, "SELECT ...", ...) // Person? + + // Records Person.fetchOne(db, primaryKey: 12) // Person? Person.fetchOne(db, key: ["name": "Arthur"]) // Person? } @@ -784,7 +789,7 @@ try dbQueue.inTransaction { db in let persons = [ ["name": "Arthur", "age": 41], - ["name": "Barbara"], + ["name": "Barbara", "age": 37], ] for person in persons { @@ -804,16 +809,19 @@ dbQueue.inDatabase { db in let statement = db.selectStatement("SELECT ...") + // Rows Row.fetch(statement, arguments: ...) // DatabaseSequence Row.fetchAll(statement, arguments: ...) // [Row] Row.fetchOne(statement, arguments: ...) // Row? + // Values Int.fetch(statement, arguments: ...) // DatabaseSequence Int.fetchAll(statement, arguments: ...) // [Int] Int.fetchOne(statement, arguments: ...) // Int? Optional.fetch(statement, arguments: ...) // DatabaseSequence Optional.fetchAll(statement, arguments: ...) // [Int?] + // RowConvertible & Records Person.fetch(statement, arguments: ...) // DatabaseSequence Person.fetchAll(statement, arguments: ...) // [Person] Person.fetchOne(statement, arguments: ...) // Person?