You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
session-ios/SessionUtilitiesKit/Database/Utilities/QueryInterfaceRequest+Utili...

27 lines
826 B
Swift

// Copyright © 2022 Rangeproof Pty Ltd. All rights reserved.
import Foundation
import GRDB
public extension QueryInterfaceRequest {
/// Returns true if the request matches a row in the database.
///
/// try Player.filter(Column("name") == "Arthur").isEmpty(db)
///
/// - parameter db: A database connection.
/// - returns: Whether the request matches a row in the database.
func isNotEmpty(_ db: Database) -> Bool {
return ((try? SQLRequest("SELECT \(exists())").fetchOne(db)) ?? false)
}
}
public extension QueryInterfaceRequest where RowDecoder: ColumnExpressible {
func select(_ selection: RowDecoder.Columns...) -> Self {
select(selection)
}
func order(_ orderings: RowDecoder.Columns...) -> QueryInterfaceRequest {
order(orderings)
}
}