exists(_:) quality of life improvements

This commit is contained in:
Gwendal Roué committed 2021-10-17 12:27:19 +02:00
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 {