OneModelRelation: add set(), clear() methods
This commit is contained in:
parent
4b9b62517b
commit
5a3acf30f4
@ -113,6 +113,13 @@ export class OneModelRelation<S extends Model, O extends Model> extends ModelRel
|
|||||||
this.cachedModels = models.filter(m => m[this.dbProperties.foreignKey] === this.getModelID())[0] || null;
|
this.cachedModels = models.filter(m => m[this.dbProperties.foreignKey] === this.getModelID())[0] || null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async set(model: O): Promise<void> {
|
||||||
|
(this.model as Model)[this.dbProperties.localKey] = model[this.dbProperties.foreignKey];
|
||||||
|
}
|
||||||
|
|
||||||
|
public async clear(): Promise<void> {
|
||||||
|
(this.model as Model)[this.dbProperties.localKey] = undefined;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class ManyModelRelation<S extends Model, O extends Model> extends ModelRelation<S, O, O[]> {
|
export class ManyModelRelation<S extends Model, O extends Model> extends ModelRelation<S, O, O[]> {
|
||||||
|
Loading…
Reference in New Issue
Block a user