|
|
|
@ -42,6 +42,14 @@ export class LendingStationAPI extends DataSource {
|
|
|
|
|
.getOne().catch(() => { return null; });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async lendingStationByTimeFrameId (id: number) {
|
|
|
|
|
await this.connection.getRepository(TimeFrame)
|
|
|
|
|
.createQueryBuilder('timeframe')
|
|
|
|
|
.relation(TimeFrame, 'lendingStation')
|
|
|
|
|
.of(id)
|
|
|
|
|
.loadOne();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async timeFrames (offset: number, limit: number) {
|
|
|
|
|
return await this.connection.getRepository(TimeFrame)
|
|
|
|
|
.createQueryBuilder('timeframe')
|
|
|
|
@ -127,6 +135,7 @@ export class LendingStationAPI extends DataSource {
|
|
|
|
|
|
|
|
|
|
async createTimeFrame (timeFrame: any) {
|
|
|
|
|
let inserts: any;
|
|
|
|
|
try {
|
|
|
|
|
await this.connection.transaction(async (entityManager: EntityManager) => {
|
|
|
|
|
if (timeFrame.to === undefined) {
|
|
|
|
|
timeFrame.to = '';
|
|
|
|
@ -149,6 +158,9 @@ export class LendingStationAPI extends DataSource {
|
|
|
|
|
.of(inserts.identifiers[0].id)
|
|
|
|
|
.set(timeFrame.lendingStationId);
|
|
|
|
|
});
|
|
|
|
|
} catch (e) {
|
|
|
|
|
return new GraphQLError('Transaction could not be completed');
|
|
|
|
|
}
|
|
|
|
|
inserts.generatedMaps[0].id = inserts.identifiers[0].id;
|
|
|
|
|
return inserts.generatedMaps[0];
|
|
|
|
|
}
|
|
|
|
|