Skip to content

Commit

Permalink
Lift the tenant check for mirrored entries (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
bt4R9 authored Dec 8, 2023
1 parent 9d25fa0 commit 25bc819
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/services/new/collection/utils/get-parents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ interface GetCollectionParentIds extends Ctx {
}

export const getParents = async ({ctx, trx, collectionIds}: GetCollectionsParentIds) => {
const {tenantId, projectId} = ctx.get('info');
const {tenantId, projectId, onlyMirrored} = ctx.get('info');

const targetTrx = getReplica(trx);

Expand All @@ -28,7 +28,7 @@ export const getParents = async ({ctx, trx, collectionIds}: GetCollectionsParent
qb1.select()
.from(CollectionModel.tableName)
.where({
[CollectionModelColumn.TenantId]: tenantId,
...(onlyMirrored ? {} : {[CollectionModelColumn.TenantId]: tenantId}),
[CollectionModelColumn.ProjectId]: projectId,
[CollectionModelColumn.DeletedAt]: null,
})
Expand All @@ -37,8 +37,12 @@ export const getParents = async ({ctx, trx, collectionIds}: GetCollectionsParent
qb2.select(`${CollectionModel.tableName}.*`)
.from(CollectionModel.tableName)
.where({
[`${CollectionModel.tableName}.${CollectionModelColumn.TenantId}`]:
tenantId,
...(onlyMirrored
? {}
: {
[`${CollectionModel.tableName}.${CollectionModelColumn.TenantId}`]:
tenantId,
}),
[`${CollectionModel.tableName}.${CollectionModelColumn.ProjectId}`]:
projectId,
[`${CollectionModel.tableName}.${CollectionModelColumn.DeletedAt}`]:
Expand Down

0 comments on commit 25bc819

Please sign in to comment.