From 74142ae618cd0884969654a92807a0482a467652 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Fri, 3 Jul 2015 21:27:02 +0200 Subject: [PATCH] README.md --- README.md | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 713bdc547..7e399dfe2 100644 --- a/README.md +++ b/README.md @@ -81,7 +81,14 @@ A rollback statement is issued if an error is thrown from the transaction block. ## Fetch Queries -**Row Queries** load database rows: +You can load rows and values from the database. + +- [Row Queries](#row-queries) +- [Value Queries](#value-queries) +- [Custom Values](#custom-values) +- + +### Row Queries ```swift dbQueue.inDatabase { db in @@ -148,7 +155,9 @@ let rows = dbQueue.inDatabase { db in ``` -**Values queries** load value types: +### Value Queries + +The library ships with built-in support for `Bool`, `Int`, `Int64`, `Double` and `String` (TODO: binary blob): ```swift dbQueue.inDatabase { db in @@ -161,9 +170,6 @@ dbQueue.inDatabase { db in } ``` -GRDB.swift ships with built-in support for `Bool`, `Int`, `Int64`, `Double` and `String` (TODO: binary blob). - - **Enum types** are supported through the `DatabaseEnum` type: ```swift @@ -193,7 +199,13 @@ let color = dbColor.value -**Custom types** can be inserted and loaded by adopting the `DatabaseValueType` protocol: +### Custom Values + +Your custom types can be inserted and loaded by adopting the `DatabaseValueType` protocol. + +As long as you can represent your type as one of the five [datatypes](https://www.sqlite.org/datatype3.html) supported by SQLite, namely NULL, INTEGER, REAL, TEXT, and BLOB, your type is fully supported by GRDB.swift. + +For example, let's define below the `DatabaseDate` type that stores and loads an NSDate in the database through its timestamp: ```swift struct DatabaseDate: DatabaseValueType {