infra(server): fix Album TypeORM relations and change ids to uuids (#1582)

* infra: make api-key primary key column a UUID

* infra: move ManyToMany relations in album entity, make ownerId ManyToOne

---------

Co-authored-by: Alex Tran <alex.tran1502@gmail.com>
This commit is contained in:
Zack Pollard
2023-02-18 20:58:55 +00:00
committed by GitHub
parent 917f1dea9f
commit 000d0a08f4
24 changed files with 368 additions and 461 deletions

View File

@@ -12,12 +12,12 @@ export class APIKeyRepository implements IKeyRepository {
return this.repository.save(dto);
}
async update(userId: string, id: number, dto: Partial<APIKeyEntity>): Promise<APIKeyEntity> {
async update(userId: string, id: string, dto: Partial<APIKeyEntity>): Promise<APIKeyEntity> {
await this.repository.update({ userId, id }, dto);
return this.repository.findOneOrFail({ where: { id: dto.id } });
}
async delete(userId: string, id: number): Promise<void> {
async delete(userId: string, id: string): Promise<void> {
await this.repository.delete({ userId, id });
}
@@ -35,7 +35,7 @@ export class APIKeyRepository implements IKeyRepository {
});
}
getById(userId: string, id: number): Promise<APIKeyEntity | null> {
getById(userId: string, id: string): Promise<APIKeyEntity | null> {
return this.repository.findOne({ where: { userId, id } });
}

View File

@@ -24,9 +24,7 @@ export class SharedLinkRepository implements ISharedLinkRepository {
},
album: {
assets: {
assetInfo: {
exifInfo: true,
},
exifInfo: true,
},
},
},
@@ -37,9 +35,7 @@ export class SharedLinkRepository implements ISharedLinkRepository {
},
album: {
assets: {
assetInfo: {
createdAt: 'ASC',
},
createdAt: 'ASC',
},
},
},
@@ -69,9 +65,7 @@ export class SharedLinkRepository implements ISharedLinkRepository {
relations: {
assets: true,
album: {
assets: {
assetInfo: true,
},
assets: true,
},
user: true,
},
@@ -109,7 +103,7 @@ export class SharedLinkRepository implements ISharedLinkRepository {
id,
album: {
assets: {
assetId,
id: assetId,
},
},
},