README.md

This commit is contained in:
Gwendal Roué committed 2015-07-06 10:57:32 +02:00
1 parent 6973a4b487
commit 6b11f02ec6
1 file changed
+3 -5
+3 -5
View File
@@ -24,21 +24,19 @@ import GRDB
// Open database connection
let dbQueue = try DatabaseQueue(path: "/path/to/database.sqlite")
// Fetch and insert values:
let redWinesCount = dbQueue.inDatabase { db in // Int
let redWinesCount = dbQueue.inDatabase { db in // Int
db.fetchOne(Int.self, "SELECT COUNT(*) FROM wines WHERE color = ?",
bindings: [Color.Red])!
}
// Insert and fetch row models:
try dbQueue.inTransaction { db in
try Person(name: "Arthur").insert(db)
return .Commit
}
dbQueue.inDatabase { db in
let persons = db.fetchAll(Person.type, "SELECT ...") // [Person]
for wine in db.fetch(Wine.type, "SELECT ...") { // AnySequence<Wine>
let persons = db.fetchAll(Person.type, "SELECT ...") // [Person]
for wine in db.fetch(Wine.type, "SELECT ...") { // AnySequence<Wine>
...
}
}