Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
override fun getVehicle(vehicleId: Long): Observable<Optional<Vehicle>> {
val statement = Vehicle.FACTORY.select_vehicle_by_id(vehicleId)
return brite.createQuery(statement.tables, statement.statement, *statement.args)
.mapToList { cursor -> Vehicle.MAPPER.map(cursor) }
.map { list -> if (list.size > 0) Optional(list[0]) else Optional(null) }
}
override fun getVehiclesAsList(): Observable<List<Vehicle>> {
val statement = Vehicle.FACTORY.select_all_vehicles()
return brite.createQuery(statement.tables, statement.statement, *statement.args)
.mapToList { cursor -> Vehicle.MAPPER.map(cursor) }
}
override fun getVehiclesAsCursor(): Observable<Cursor> {
val statement = Vehicle.FACTORY.select_all_vehicles()
return brite.createQuery(statement.tables, statement.statement, *statement.args)
.map { query: SqlBrite.Query -> query.run() }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.