mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-26 04:07:50 +00:00
README.md
This commit is contained in:
1 parent
f5dc639211
commit
f4def1966b
1 file changed
+8
-12
@@ -59,6 +59,9 @@ extension PointOfInterest {
|
||||
// snip: conformance to database protocols
|
||||
}
|
||||
|
||||
let title = SQLColumn("title")
|
||||
let favorite = SQLColumn("favorite")
|
||||
|
||||
try dbQueue.inDatabase { db in
|
||||
// INSERT INTO "pointOfInterests" ...
|
||||
var berlin = PointOfInterest(id: nil, title: "Berlin", favorite: false, coordinate: CLLocationCoordinate2DMake(52.52437, 13.41053))
|
||||
@@ -69,21 +72,14 @@ try dbQueue.inDatabase { db in
|
||||
berlin.favorite = true
|
||||
try berlin.update(db)
|
||||
|
||||
// SELECT * FROM "pointOfInterests"
|
||||
for poi in PointOfInterest.all().fetch(db) {
|
||||
print(poi.title, poi.coordinate)
|
||||
}
|
||||
}
|
||||
|
||||
let title = SQLColumn("title")
|
||||
let favorite = SQLColumn("favorite")
|
||||
|
||||
let favorites = dbQueue.inDatabase { db in
|
||||
// SELECT * FROM "pointOfInterests" WHERE "favorite" ORDER BY "title"
|
||||
PointOfInterest.filter(favorite).order(title).fetchAll(db)
|
||||
let favorites = PointOfInterest.filter(favorite).order(title).fetchAll(db)
|
||||
|
||||
// Fetch from SQL
|
||||
let pois = PointOfInterest.fetchAll(db, "SELECT * FROM pointOfInterests")
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
### Documentation
|
||||
|
||||
|
||||
Reference in new issue
Block a user