diff --git a/src/datasources/db/lendingstationAPI.ts b/src/datasources/db/lendingstationAPI.ts index 02ab251..f838301 100644 --- a/src/datasources/db/lendingstationAPI.ts +++ b/src/datasources/db/lendingstationAPI.ts @@ -25,6 +25,7 @@ import { LendingStation } from '../../model/LendingStation'; import { TimeFrame } from '../../model/TimeFrame'; import { ActionLogger, genDateRange, DBUtils, LockUtils } from './utils'; import { ResourceLockedError } from '../../errors/ResourceLockedError'; +import { NotFoundError } from '../../errors/NotFoundError'; export class LendingStationAPI extends DataSource { connection : Connection @@ -247,7 +248,7 @@ export class LendingStationAPI extends DataSource { .set({ ...timeFrame }) .where('id = :id', { id: timeFrame.id }) .execute() - .then(value => { if (value.affected !== 1) { throw new UserInputError('ID not found'); } }); + .then(value => { if (value.affected !== 1) { throw new NotFoundError('TimeFrame', 'id', timeFrame.id); } }); }); !keepLock && await this.unlockTimeFrame(timeFrame.id, userId); return this.timeFrameById(timeFrame.id); diff --git a/src/datasources/db/providerAPI.ts b/src/datasources/db/providerAPI.ts index 30fabc3..d43541e 100644 --- a/src/datasources/db/providerAPI.ts +++ b/src/datasources/db/providerAPI.ts @@ -179,15 +179,17 @@ export class ProviderAPI extends DataSource { } async createOrganisation (organisation: any) { - let inserts: any = null; + let createdOrganisation: any = null; await this.connection.transaction(async (entityManager: EntityManager) => { - inserts = await entityManager.getRepository(Organisation) + const result = await entityManager.getRepository(Organisation) .createQueryBuilder('o') .insert() .values([organisation]) .execute(); + createdOrganisation = await entityManager.getRepository(Organisation).findOne(result.identifiers[0].id); }); - return inserts.generatedMaps[0]; + + return createdOrganisation; } async lockOrganisation (id: number, userId: number) { diff --git a/src/schema/type-defs.ts b/src/schema/type-defs.ts index b55e6a8..a8cd2be 100644 --- a/src/schema/type-defs.ts +++ b/src/schema/type-defs.ts @@ -840,7 +840,7 @@ export default gql` address: AddressCreateInput! name: String! "registration number of association" - associationNo: String! + associationNo: String "If Club, at what court registered" registeredAt: String contactInformationId: ID