lib/src/orm/builder/Builder.ts

25 lines
940 B
TypeScript
Raw Normal View History

2021-06-03 03:36:25 +00:00
import {ErrorWithContext} from '../../util'
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.
*/
@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.`)
}
return Container.getContainer().make<ResultIterable>(ResultIterable, this.finalize(), this.registeredConnection)
2021-06-02 01:59:40 +00:00
}
}