mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-03-19 07:20:00 +00:00
30 lines
660 B
TypeScript
30 lines
660 B
TypeScript
export class BaseRepository {
|
|
private nextRelations: string[];
|
|
|
|
constructor() {
|
|
this.nextRelations = [];
|
|
}
|
|
|
|
/**
|
|
* Primes the specified relation(s) to be used in the next database operation.
|
|
* Can be chained.
|
|
*/
|
|
public with(relations: string | string[]): this {
|
|
if (Array.isArray(relations)) {
|
|
this.nextRelations.push(...relations);
|
|
} else {
|
|
this.nextRelations.push(relations);
|
|
}
|
|
|
|
return this;
|
|
}
|
|
|
|
/**
|
|
* Gets and resets the relations primed using with()
|
|
*/
|
|
protected getRelations(): string[] {
|
|
const relations = this.nextRelations || [];
|
|
this.nextRelations = [];
|
|
return relations;
|
|
}
|
|
}
|