diff --git a/plugins/catalog-backend/src/catalog/DatabaseEntitiesCatalog.ts b/plugins/catalog-backend/src/catalog/DatabaseEntitiesCatalog.ts index d13ac9a1ba..606b6dc475 100644 --- a/plugins/catalog-backend/src/catalog/DatabaseEntitiesCatalog.ts +++ b/plugins/catalog-backend/src/catalog/DatabaseEntitiesCatalog.ts @@ -49,13 +49,16 @@ export class DatabaseEntitiesCatalog implements EntitiesCatalog { ); } - async addOrUpdateEntity(entity: Entity): Promise { + async addOrUpdateEntity( + entity: Entity, + locationId?: string, + ): Promise { await this.policy.enforce(entity); return await this.database.transaction(async tx => { let response: DbEntityResponse; if (entity.metadata.uid) { - response = await this.database.updateEntity(tx, { entity }); + response = await this.database.updateEntity(tx, { locationId, entity }); } else { const existing = await this.entityByNameInternal( tx, @@ -64,9 +67,12 @@ export class DatabaseEntitiesCatalog implements EntitiesCatalog { entity.metadata.namespace, ); if (existing) { - response = await this.database.updateEntity(tx, { entity }); + response = await this.database.updateEntity(tx, { + locationId, + entity, + }); } else { - response = await this.database.addEntity(tx, { entity }); + response = await this.database.addEntity(tx, { locationId, entity }); } } diff --git a/plugins/catalog-backend/src/catalog/types.ts b/plugins/catalog-backend/src/catalog/types.ts index 61fba33ebf..2ef5fd9e56 100644 --- a/plugins/catalog-backend/src/catalog/types.ts +++ b/plugins/catalog-backend/src/catalog/types.ts @@ -30,7 +30,7 @@ export type EntitiesCatalog = { namespace: string | undefined, name: string, ): Promise; - addOrUpdateEntity(entity: Entity): Promise; + addOrUpdateEntity(entity: Entity, locationId?: string): Promise; removeEntityByUid(uid: string): Promise; };