2021-06-03 03:36:25 +00:00
|
|
|
import {ErrorWithContext} from '../../util'
|
2021-07-25 14:15:01 +00:00
|
|
|
import {Container, Injectable} from '../../di'
|
2021-06-03 03:36:25 +00:00
|
|
|
import {ResultIterable} from './result/ResultIterable'
|
|
|
|
import {QueryRow} from '../types'
|
|
|
|
import {AbstractBuilder} from './AbstractBuilder'
|
|
|
|
import {AbstractResultIterable} from './result/AbstractResultIterable'
|
2021-06-02 01:59:40 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Implementation of the abstract builder class that returns simple QueryRow objects.
|
|
|
|
*/
|
2021-07-25 14:15:01 +00:00
|
|
|
@Injectable()
|
2021-06-02 01:59:40 +00:00
|
|
|
export class Builder extends AbstractBuilder<QueryRow> {
|
|
|
|
public getNewInstance(): AbstractBuilder<QueryRow> {
|
2021-06-03 03:36:25 +00:00
|
|
|
return Container.getContainer().make<Builder>(Builder)
|
2021-06-02 01:59:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public getResultIterable(): AbstractResultIterable<QueryRow> {
|
2021-06-03 03:36:25 +00:00
|
|
|
if ( !this.registeredConnection ) {
|
2021-06-02 01:59:40 +00:00
|
|
|
throw new ErrorWithContext(`No connection specified to fetch iterator for query.`)
|
|
|
|
}
|
|
|
|
|
2021-11-11 22:42:37 +00:00
|
|
|
return Container.getContainer().make<ResultIterable>(ResultIterable, this.finalize(), this.registeredConnection)
|
2021-06-02 01:59:40 +00:00
|
|
|
}
|
|
|
|
}
|