You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
lib/src/orm/builder/result/AbstractResultIterable.ts

52 lines
1.4 KiB

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>
}