garrettmills
1d5056b753
All checks were successful
continuous-integration/drone/push Build is passing
52 lines
1.4 KiB
TypeScript
52 lines
1.4 KiB
TypeScript
import {Collection, Iterable} from '../../../util'
|
|
import {Connection} from '../../connection/Connection'
|
|
import {AbstractBuilder} from '../AbstractBuilder'
|
|
|
|
/**
|
|
* Base Iterable class that generates the results of a Builder query.
|
|
*/
|
|
export abstract class AbstractResultIterable<T> extends Iterable<T> {
|
|
protected constructor(
|
|
/** The builder whose results should be iterated */
|
|
public readonly builder: AbstractBuilder<T>,
|
|
|
|
/** The connection on which to execute the builder. */
|
|
public readonly connection: Connection,
|
|
) {
|
|
super()
|
|
}
|
|
|
|
/**
|
|
* Get the SQL string for the SELECT query for this iterable.
|
|
*/
|
|
public abstract get selectSQL(): string
|
|
|
|
/**
|
|
* Get the result at index i.
|
|
* @param i
|
|
*/
|
|
public abstract at(i: number): Promise<T | undefined>
|
|
|
|
/**
|
|
* Get the results starting at index `start` and ending at index `end`.
|
|
* @param start
|
|
* @param end
|
|
*/
|
|
public abstract range(start: number, end: number): Promise<Collection<T>>
|
|
|
|
/**
|
|
* Count the number of results of the query.
|
|
*/
|
|
public abstract count(): Promise<number>
|
|
|
|
/**
|
|
* Return all items resulting from this query.
|
|
*/
|
|
public abstract all(): Promise<Collection<T>>
|
|
|
|
/**
|
|
* Create a new iterable based on this query.
|
|
*/
|
|
public abstract clone(): AbstractResultIterable<T>
|
|
}
|