mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-26 04:07:50 +00:00
WIP: GRDB2MigrationGuide.md
This commit is contained in:
1 parent
33ec30438d
commit
fa04627ece
1 file changed
+6
-4
@@ -124,10 +124,10 @@ That is because the library requires Swift 4.1, which ships with Xcode 9.3, unab
|
||||
|
||||
## If You Use Database Queues
|
||||
|
||||
With GRDB 2, you used to access the database through the `inDatabase` or `inTransaction` DatabaseQueue methods:
|
||||
With GRDB 2, you used to access the database through the `inDatabase` or `inTransaction` [DatabaseQueue] methods:
|
||||
|
||||
```swift
|
||||
// Typical GRDB 2
|
||||
// GRDB 2
|
||||
let players = try dbQueue.inDatabase { db in
|
||||
try Player.fetchAll(db)
|
||||
}
|
||||
@@ -166,13 +166,13 @@ let balance = try dbQueue.write { db in
|
||||
}
|
||||
```
|
||||
|
||||
The purpose of the new `read` and `write` methods is to soothe the "transaction mental load" of GRDB 2, inherited from FMDB. All developers can *forget* to open transactions, with the unfortunate consequence that the database may end up containing inconsistent values. Experienced developers may *wonder* whether they should open transactions or not, even when this doesn't matter a lot.
|
||||
The purpose of the new `read` and `write` methods is to soothe the "transaction mental load" of GRDB 2, a legacy of the [FMDB] heritage. All developers can *forget* to open transactions, with the unfortunate consequence that the database may end up containing inconsistent values. Experienced developers may *wonder* whether they should open transactions or not, even when this doesn't matter a lot.
|
||||
|
||||
With GRDB 3, use `read` when you need to read values. It's impossible to write within a `read` block, which means that you can be sure that no unwanted side effect can happen.
|
||||
|
||||
When you need to write, use `write`: your database changes are automatically wrapped in a transaction, with the guarantee that all changes are applied, or, should any error happen, none at all.
|
||||
|
||||
Of course, precise transaction handling is still possible. Check the updated [Transactions and Savepoints] chapter.
|
||||
Of course, precise transaction handling sometimes matter. Check the updated [Transactions and Savepoints] chapter.
|
||||
|
||||
|
||||
## If You Use Database Pools
|
||||
@@ -189,3 +189,5 @@ Of course, precise transaction handling is still possible. Check the updated [Tr
|
||||
[DatabaseMigrator]: ../README.md#migrations
|
||||
[database observation tools]: ../README.md#database-changes-observation
|
||||
[Transactions and Savepoints]: ../README.md#transactions-and-savepoints
|
||||
[DatabaseQueue]: ../README.md#database-queues
|
||||
[FMDB]: http://github.com/ccgus/fmdb
|
||||
Reference in new issue
Block a user