SQLTableBuilder documentation

This commit is contained in:
Gwendal Roué committed 2016-08-06 14:54:53 +02:00
1 parent 0ab4df99b7
commit 3de4920385
1 file changed
+2
+2
View File
@@ -2116,6 +2116,7 @@ For an efficient algorithm which synchronizes the content of a database table wi
**The query interface lets you write pure Swift instead of SQL:**
```swift
try db.create(table: "wines") { t in ... }
let count = Wine.filter(color == Color.Red).fetchCount(db)
let wines = Wine.filter(origin == "Burgundy").order(price).fetchAll(db)
```
@@ -2123,6 +2124,7 @@ let wines = Wine.filter(origin == "Burgundy").order(price).fetchAll(db)
Please bear in mind that the query interface can not generate all possible SQL queries. You may also *prefer* writing SQL, and this is just OK. From little snippets to full queries, your SQL skills are welcome:
```swift
try db.execute("CREATE TABLE wines (...)")
let count = Wine.filter(sql: "color = ?", arguments: [Color.Red]).fetchCount(db)
let wines = Wine.fetchAll(db, "SELECT * FROM wines WHERE origin = ? ORDER BY price", arguments: ["Burgundy"])
```