mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-28 04:24:20 +00:00
24 lines
712 B
Swift
24 lines
712 B
Swift
/// A protocol for all types that can fetch values from a database.
|
|
public protocol DatabaseReader {
|
|
func nonIsolatedRead<T>(block: (db: Database) throws -> T) rethrows -> T
|
|
}
|
|
|
|
extension DatabaseQueue : DatabaseReader {
|
|
|
|
/// Synonym for DatabaseQueue.inDatabase()
|
|
public func nonIsolatedRead<T>(block: (db: Database) throws -> T) rethrows -> T {
|
|
return try inDatabase(block)
|
|
}
|
|
}
|
|
|
|
extension DatabasePool : DatabaseReader {
|
|
}
|
|
|
|
extension Database : DatabaseReader {
|
|
/// Conformance to the DatabaseReader protocol.
|
|
/// Don't use this method directly.
|
|
public func nonIsolatedRead<T>(block: (db: Database) throws -> T) rethrows -> T {
|
|
return try block(db: self)
|
|
}
|
|
}
|