mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-30 04:28:44 +00:00
exists(_:) quality of life improvements
This commit is contained in:
1 parent
cbd68099a9
commit
7a046fb27e
2 files changed
+104
No files matched your search
@@ -410,6 +410,21 @@ extension QueryInterfaceRequest {
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Check Existence
|
||||
|
||||
extension QueryInterfaceRequest {
|
||||
#warning("TODO: test & document")
|
||||
/// Returns whether a row exists in this request.
|
||||
///
|
||||
/// try Player.filter(Column("name") == "Arthur").exists(db)
|
||||
///
|
||||
/// - parameter db: A database connection.
|
||||
/// - returns: Whether a row exists in this request
|
||||
public func exists(_ db: Database) throws -> Bool {
|
||||
try SQLRequest("SELECT \(exists())").fetchOne(db)!
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Batch Delete
|
||||
|
||||
extension QueryInterfaceRequest {
|
||||
|
||||
Reference in new issue
Block a user