@@ -11,7 +11,7 @@ public enum Queries {
1111 /// Allows for the erasing of the database so a query can be
1212 /// passed around and be able to be executed without
1313 /// having the caller worry about by what.
14- public struct WithDatabase < Base: Queryable > : Queryable {
14+ public struct WithDatabase < Base: DatabaseQuery > : DatabaseQuery , Query {
1515 /// The original query that requires a database
1616 let base : Base
1717 /// The database to execute the query in
@@ -43,10 +43,16 @@ public enum Queries {
4343 ) -> QueryObservation < Input , Output > {
4444 return base. observe ( with: input, in: database, handle: handle, cancelled: cancelled)
4545 }
46+
47+ public func execute(
48+ with input: Base . Input
49+ ) async throws -> Base . Output {
50+ return try await base. execute ( with: input, in: database)
51+ }
4652 }
4753
4854 /// Applies a transform to the queries result
49- public struct Map < Base: Queryable , Output: Sendable > : Queryable {
55+ public struct Map < Base: DatabaseQuery , Output: Sendable > : DatabaseQuery {
5056 /// The upstream query to transform
5157 let base : Base
5258 /// The transform to apply to the output
@@ -72,7 +78,7 @@ public enum Queries {
7278 }
7379
7480 /// Applies a transform to the queries result
75- public struct Just < Input, Output> : Queryable
81+ public struct Just < Input, Output> : DatabaseQuery
7682 where Input: Sendable , Output: Sendable
7783 {
7884 let output : Output
@@ -100,8 +106,8 @@ public enum Queries {
100106 }
101107 }
102108
103- public struct Then < First, Second> : Queryable
104- where First: Queryable , Second: Queryable ,
109+ public struct Then < First, Second> : DatabaseQuery
110+ where First: DatabaseQuery , Second: DatabaseQuery ,
105111 First. Output == Second . Input
106112 {
107113 let first : First
@@ -124,7 +130,7 @@ public enum Queries {
124130 }
125131}
126132
127- public extension Queryable {
133+ public extension DatabaseQuery {
128134 func with( database: any Database ) -> Queries . WithDatabase < Self > {
129135 return Queries . WithDatabase ( base: self , database: database)
130136 }
0 commit comments