mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-26 04:07:50 +00:00
Remove RowModel API Quick Tour
This commit is contained in:
1 parent
33f58759f1
commit
4b4632eca7
1 file changed
-42
@@ -122,7 +122,6 @@ To fiddle with the library, open the `GRDB.xcworkspace` workspace: it contains a
|
||||
- [Error Handling](#error-handling)
|
||||
- [Migrations](#migrations)
|
||||
- [Row Models](#row-models)
|
||||
- [RowModel API Quick Tour](#rowmodel-api-quick-tour)
|
||||
- [Core Methods](#core-methods)
|
||||
- [Fetching Row Models](#fetching-row-models)
|
||||
- [Ad Hoc Subclasses](#ad-hoc-subclasses)
|
||||
@@ -815,7 +814,6 @@ Yet, it does a few things well:
|
||||
}
|
||||
```
|
||||
|
||||
- [RowModel API Quick Tour](#rowmodel-api-quick-tour)
|
||||
- [Core Methods](#core-methods)
|
||||
- [Fetching Row Models](#fetching-row-models)
|
||||
- [Ad Hoc Subclasses](#ad-hoc-subclasses)
|
||||
@@ -826,46 +824,6 @@ Yet, it does a few things well:
|
||||
- [Advice](#advice)
|
||||
|
||||
|
||||
### RowModel API Quick Tour
|
||||
|
||||
RowModel can be **stored** or **deleted**:
|
||||
|
||||
```swift
|
||||
class Person : RowModel { ... }
|
||||
let person = Person(...)
|
||||
try person.insert(db) // INSERT INTO persons (...) VALUES (...)
|
||||
try person.update(db) // UPDATE persons SET ...
|
||||
try person.save(db) // inserts or updates
|
||||
try person.delete(db) // DELETE FROM persons WHERE ...
|
||||
```
|
||||
|
||||
Database tables usually have a **primary key**:
|
||||
|
||||
```swift
|
||||
person.exists(db) // true or false
|
||||
try person.reload(db) // SELECT * FROM persons WHERE ...
|
||||
Person.fetchOne(db, primaryKey: 12) // Person?
|
||||
Citizenship.fetchOne(db, key: ["personId": 12, "countryId": 45]) // Citizenship?
|
||||
```
|
||||
|
||||
RowModels can be fetched from custom **SQL queries**...
|
||||
|
||||
```swift
|
||||
Person.fetch(db, "SELECT ...", arguments: ...) // AnySequence<Person>
|
||||
Person.fetchAll(db, "SELECT ...", arguments: ...) // [Person]
|
||||
Person.fetchOne(db, "SELECT ...", arguments: ...) // Person?
|
||||
```
|
||||
|
||||
... or from **prepared statements**:
|
||||
|
||||
```swift
|
||||
let statement = db.selectStatement("SELECT ...")
|
||||
Person.fetch(statement, arguments: ...) // AnySequence<Person>
|
||||
Person.fetchAll(statement, arguments: ...) // [Person]
|
||||
Person.fetchOne(statement, arguments: ...) // Person?
|
||||
```
|
||||
|
||||
|
||||
### Core Methods
|
||||
|
||||
Subclasses opt in RowModel features by overriding all or part of the core methods that define their relationship with the database:
|
||||
|
||||
Reference in new issue
Block a user