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.
|
|
|
import {Model} from '../Model.ts'
|
|
|
|
import {HasOneOrMany} from './HasOneOrMany.ts'
|
|
|
|
import {Collection} from '../../../../lib/src/collection/Collection.ts'
|
|
|
|
|
|
|
|
export class HasMany<T extends Model<T>, T2 extends Model<T2>> extends HasOneOrMany<T, T2> {
|
|
|
|
protected _value?: Collection<T2>
|
|
|
|
protected _loaded = false
|
|
|
|
|
|
|
|
public async get(): Promise<Collection<T2>> {
|
|
|
|
return this.fetch().collect()
|
|
|
|
}
|
|
|
|
|
|
|
|
public set_value(related: Collection<T2>) {
|
|
|
|
this._loaded = true
|
|
|
|
this._value = related.clone()
|
|
|
|
}
|
|
|
|
|
|
|
|
public get_value(): Collection<T2> | undefined {
|
|
|
|
return this._value
|
|
|
|
}
|
|
|
|
|
|
|
|
public is_loaded(): boolean {
|
|
|
|
return this._loaded
|
|
|
|
}
|
|
|
|
}
|