Skip to content

Session doesn't support decoding & paging mode #31

@gmilos

Description

@gmilos

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/enhancementImprovements to existing feature.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions