find(_:key:)
Returns the record identified by a primary key, or throws an error if the record does not exist.
static func find(_ db: Database, key: some DatabaseValueConvertible) throws -> Self
Parameters
Returns
A record.
Throws
A DatabaseError
whenever an SQLite error occurs, or a recordNotFound(databaseTableName:key:)
if the record does not exist in the database.
For example:
try dbQueue.read { db in
let player = try Player.find(db, key: 123)
let country = try Country.find(db, key: "FR")
}