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