-
Notifications
You must be signed in to change notification settings - Fork 34
Session doesn't support decoding & paging mode #31
Copy link
Copy link
Open
Labels
kind/enhancementImprovements to existing feature.Improvements to existing feature.
Description
Session supports couple of query types that decode the data type automatically, e.g.:
swift-cassandra-client/Sources/CassandraClient/Session.swift
Lines 133 to 145 in 4c395e6
| public func query<T: Decodable>( | |
| _ query: String, | |
| parameters: [CassandraClient.Statement.Value] = [], | |
| options: CassandraClient.Statement.Options = .init(), | |
| on eventLoop: EventLoop? = .none, | |
| logger: Logger? = .none | |
| ) -> EventLoopFuture<[T]> { | |
| self.query(query, parameters: parameters, options: options, on: eventLoop, logger: logger).flatMapThrowing { rows in | |
| try rows.map { row in | |
| try T(from: CassandraClient.RowDecoder(row: row)) | |
| } | |
| } | |
| } |
Separately, Session supports paging queries, for example:
swift-cassandra-client/Sources/CassandraClient/Session.swift
Lines 173 to 189 in 4c395e6
| public func query( | |
| _ query: String, | |
| parameters: [CassandraClient.Statement.Value] = [], | |
| pageSize: Int32, | |
| options: CassandraClient.Statement.Options = .init(), | |
| on eventLoop: EventLoop? = .none, | |
| logger: Logger? = .none | |
| ) -> EventLoopFuture<CassandraClient.PaginatedRows> { | |
| do { | |
| let statement = try CassandraClient.Statement(query: query, parameters: parameters, options: options) | |
| return self.execute(statement: statement, pageSize: pageSize, on: eventLoop, logger: logger) | |
| } catch { | |
| let eventLoop = eventLoop ?? eventLoopGroup.next() | |
| return eventLoop.makeFailedFuture(error) | |
| } | |
| } | |
| } |
What's missing is a query that'd do both paging & decoding.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
kind/enhancementImprovements to existing feature.Improvements to existing feature.