chore(server): change save -> update in asset repository (#8055)

* `save` -> `update`

* change return type

* include relations

* fix tests

* remove when mocks

* fix

* stricter typing

* simpler type
This commit is contained in:
Mert
2024-03-19 22:42:10 -04:00
committed by GitHub
parent 9e4bab7494
commit 2daed747cd
14 changed files with 128 additions and 138 deletions

View File

@@ -6,6 +6,8 @@ import {
AssetSearchOptions,
AssetStats,
AssetStatsOptions,
AssetUpdateAllOptions,
AssetUpdateOptions,
IAssetRepository,
LivePhotoSearchOptions,
MapMarker,
@@ -275,7 +277,7 @@ export class AssetRepository implements IAssetRepository {
@GenerateSql({ params: [[DummyValue.UUID], { deviceId: DummyValue.STRING }] })
@Chunked()
async updateAll(ids: string[], options: Partial<AssetEntity>): Promise<void> {
async updateAll(ids: string[], options: AssetUpdateAllOptions): Promise<void> {
await this.repository.update({ id: In(ids) }, options);
}
@@ -289,21 +291,8 @@ export class AssetRepository implements IAssetRepository {
await this.repository.restore({ id: In(ids) });
}
async save(asset: Partial<AssetEntity>): Promise<AssetEntity> {
const { id } = await this.repository.save(asset);
return this.repository.findOneOrFail({
where: { id },
relations: {
exifInfo: true,
owner: true,
smartInfo: true,
tags: true,
faces: {
person: true,
},
},
withDeleted: true,
});
async update(asset: AssetUpdateOptions): Promise<void> {
await this.repository.update(asset.id, asset);
}
async remove(asset: AssetEntity): Promise<void> {