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.
27 lines
757 B
27 lines
757 B
import ResultOperator from '../builder/type/result/ResultOperator.ts'
|
|
import {Model} from './Model.ts'
|
|
import {Injectable} from '../../../di/src/decorator/Injection.ts'
|
|
import {Container} from '../../../di/src/Container.ts'
|
|
import {QueryRow} from '../db/types.ts'
|
|
import Instantiable from '../../../di/src/type/Instantiable.ts'
|
|
|
|
@Injectable()
|
|
export default class ModelResultOperator extends ResultOperator<Model> {
|
|
|
|
constructor(
|
|
protected injector: Container,
|
|
protected ModelClass: Instantiable<Model>,
|
|
) {
|
|
super();
|
|
}
|
|
|
|
inflate_row(row: QueryRow): Model {
|
|
return this.injector.make(this.ModelClass).assume_from_source(row)
|
|
}
|
|
|
|
deflate_row(item: Model): QueryRow {
|
|
return item.to_row()
|
|
}
|
|
|
|
}
|