Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Session doesn't support decoding & paging mode #31

Open
gmilos opened this issue Aug 1, 2024 · 0 comments
Open

Session doesn't support decoding & paging mode #31

gmilos opened this issue Aug 1, 2024 · 0 comments
Labels
kind/enhancement Improvements to existing feature.

Comments

@gmilos
Copy link
Contributor

gmilos commented Aug 1, 2024

Session supports couple of query types that decode the data type automatically, e.g.:

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:

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.

@gmilos gmilos added the kind/enhancement Improvements to existing feature. label Aug 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement Improvements to existing feature.
Projects
None yet
Development

No branches or pull requests

1 participant