Reorganize project. Add folder for shared code between backend/dashboard. Switch from jest to ava for tests.
This commit is contained in:
parent
80a82fe348
commit
16111bbe84
162 changed files with 11056 additions and 9900 deletions
30
backend/src/data/BaseRepository.ts
Normal file
30
backend/src/data/BaseRepository.ts
Normal file
|
@ -0,0 +1,30 @@
|
|||
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;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue