mirror of
https://github.com/immich-app/immich.git
synced 2026-03-01 01:59:06 +03:00
feat: asset copy (#23172)
This commit is contained in:
@@ -397,4 +397,18 @@ export class AlbumRepository {
|
||||
.orderBy('assetCount', 'desc')
|
||||
.execute();
|
||||
}
|
||||
|
||||
@GenerateSql({ params: [{ sourceAssetId: DummyValue.UUID, targetAssetId: DummyValue.UUID }] })
|
||||
async copyAlbums({ sourceAssetId, targetAssetId }: { sourceAssetId: string; targetAssetId: string }) {
|
||||
return this.db
|
||||
.insertInto('album_asset')
|
||||
.expression((eb) =>
|
||||
eb
|
||||
.selectFrom('album_asset')
|
||||
.select((eb) => ['album_asset.albumsId', eb.val(targetAssetId).as('assetsId')])
|
||||
.where('album_asset.assetsId', '=', sourceAssetId),
|
||||
)
|
||||
.onConflict((oc) => oc.doNothing())
|
||||
.execute();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { Kysely } from 'kysely';
|
||||
import { InjectKysely } from 'nestjs-kysely';
|
||||
import { DummyValue, GenerateSql } from 'src/decorators';
|
||||
import { DB } from 'src/schema';
|
||||
|
||||
export class SharedLinkAssetRepository {
|
||||
@@ -15,4 +16,18 @@ export class SharedLinkAssetRepository {
|
||||
|
||||
return deleted.map((row) => row.assetsId);
|
||||
}
|
||||
|
||||
@GenerateSql({ params: [{ sourceAssetId: DummyValue.UUID, targetAssetId: DummyValue.UUID }] })
|
||||
async copySharedLinks({ sourceAssetId, targetAssetId }: { sourceAssetId: string; targetAssetId: string }) {
|
||||
return this.db
|
||||
.insertInto('shared_link_asset')
|
||||
.expression((eb) =>
|
||||
eb
|
||||
.selectFrom('shared_link_asset')
|
||||
.select((eb) => [eb.val(targetAssetId).as('assetsId'), 'shared_link_asset.sharedLinksId'])
|
||||
.where('shared_link_asset.assetsId', '=', sourceAssetId),
|
||||
)
|
||||
.onConflict((oc) => oc.doNothing())
|
||||
.execute();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -162,4 +162,9 @@ export class StackRepository {
|
||||
.where('asset.id', '=', assetId)
|
||||
.executeTakeFirst();
|
||||
}
|
||||
|
||||
@GenerateSql({ params: [{ sourceId: DummyValue.UUID, targetId: DummyValue.UUID }] })
|
||||
merge({ sourceId, targetId }: { sourceId: string; targetId: string }) {
|
||||
return this.db.updateTable('asset').set({ stackId: targetId }).where('asset.stackId', '=', sourceId).execute();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user