You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/// - database: The ``Blackbird/Database`` instance to update.
1015
+
/// - primaryKey: The single-column primary-key value to update.
1016
+
/// - changes: A block, passed a ``Blackbird/Database/Core`` and the matching instance, in which changes can be made to `instance` and other synchronous database operations may be called on `core`. If an error is thrown from within the block, the transaction will be canceled and no changes will be written.
1017
+
/// - Returns: The value returned by the `changes` block, if any.
1018
+
/// - Throws: Any error thrown from the `changes` block, or ``BlackbirdModelError/primaryKeyNotFound(value:)`` if no row exists in the database with the given `primaryKey` value.
1019
+
///
1020
+
/// This method is preferable to ``write(to:)-(Blackbird.Database)`` to avoid race conditions.
if !instance.changedColumns(in: database).isEmpty {try instance.write(to: core)}
1046
+
return result
1047
+
}
1048
+
1007
1049
/// Write this instance to a database.
1008
1050
/// - Parameter database: The ``Blackbird/Database`` instance to write to.
1051
+
///
1052
+
/// For updating existing instances in the database, ``modify(in:primaryKey:changes:)-(Blackbird.Database,_,_)`` is preferable to avoid race conditions.
/// - core: The isolated ``Blackbird/Database/Core`` provided to the transaction.
1016
1060
///
1017
1061
/// For use only when the database actor is isolated within calls to ``Blackbird/Database/transaction(_:)`` or ``Blackbird/Database/cancellableTransaction(_:)``.
1062
+
///
1063
+
/// For updating existing instances in the database, ``modify(in:primaryKey:changes:)-(Blackbird.Database.Core,_,_)`` is preferable to avoid race conditions.
0 commit comments