From c4fa174fadd6555e391d592b6073805a08ec5e24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Thu, 10 Dec 2015 08:14:36 +0100 Subject: [PATCH] DatabasePersistable documentation (#12) --- GRDB/Core/Protocols/DatabasePersistable.swift | 25 ++++++++++++++----- GRDB/Record/Record.swift | 3 ++- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/GRDB/Core/Protocols/DatabasePersistable.swift b/GRDB/Core/Protocols/DatabasePersistable.swift index 55834431d..e40df1f73 100644 --- a/GRDB/Core/Protocols/DatabasePersistable.swift +++ b/GRDB/Core/Protocols/DatabasePersistable.swift @@ -92,7 +92,8 @@ public protocol DatabasePersistable : DatabaseTableMapping { /// match any row in the database. func update(db: Database) throws - /// Saves `self` in the database. + /// Executes an INSERT or an UPDATE statement so that `self` is saved in + /// the database. /// /// If the receiver has a non-nil primary key and a matching row in the /// database, this method performs an update. @@ -146,27 +147,39 @@ public extension DatabasePersistable { // MARK: - CRUD - /// The default implementation for insert(). It invokes performInsert(). + /// Executes an INSERT statement. + /// + /// The default implementation for insert() invokes performInsert(). mutating func insert(db: Database) throws { try performInsert(db) } - /// The default implementation for update(). It invokes performUpdate(). + /// Executes an UPDATE statement. + /// + /// The default implementation for update() invokes performUpdate(). func update(db: Database) throws { try performUpdate(db) } - /// The default implementation for save(). It invokes performSave(). + /// Executes an INSERT or an UPDATE statement so that `self` is saved in + /// the database. + /// + /// The default implementation for save() invokes performSave(). mutating func save(db: Database) throws { try performSave(db) } - /// The default implementation for delete(). It invokes performDelete(). + /// Executes a DELETE statement. + /// + /// The default implementation for delete() invokes performDelete(). func delete(db: Database) throws -> Bool { return try performDelete(db) } - /// The default implementation for exists(). It invokes performExists(). + /// Returns true if and only if the primary key matches a row in + /// the database. + /// + /// The default implementation for exists() invokes performExists(). func exists(db: Database) -> Bool { return performExists(db) } diff --git a/GRDB/Record/Record.swift b/GRDB/Record/Record.swift index bcd11c4d1..48841a59d 100644 --- a/GRDB/Record/Record.swift +++ b/GRDB/Record/Record.swift @@ -282,7 +282,8 @@ public class Record : RowConvertible, DatabaseTableMapping, DatabasePersistable databaseEdited = false } - /// Saves the record in the database. + /// Executes an INSERT or an UPDATE statement so that `self` is saved in + /// the database. /// /// If the record has a non-nil primary key and a matching row in the /// database, this method performs an update.