Skip to content

Commit

Permalink
we have withDeleted at home
Browse files Browse the repository at this point in the history
  • Loading branch information
mertalev committed May 8, 2024
1 parent 308ebd4 commit fb19328
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 5 additions & 1 deletion server/src/prisma/find-non-deleted.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ import { Prisma } from '@prisma/client';
const excludeDeleted = ({ args, query }: { args: any; query: any }) => {
if (args.where === undefined) {
args.where = { deletedAt: null };
} else if (args.where.deletedAt === undefined) {
} else if (
args.where.deletedAt === undefined &&
!args.where.OR?.some(({ deletedAt }: any) => deletedAt !== undefined) &&
!args.where.AND?.some(({ deletedAt }: any) => deletedAt !== undefined)
) {
args.where.deletedAt = null;
}

Expand Down
2 changes: 2 additions & 0 deletions server/src/repositories/asset.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -747,6 +747,7 @@ export class AssetRepository implements IAssetRepository {
isVisible: true,
updatedAt: { lte: updatedUntil },
AND: [{ fileCreatedAt: { lt: lastCreationDate } }, { id: { lt: lastId } }],
OR: [{ deletedAt: null }, { deletedAt: { not: null } }],
},
include: {
exifInfo: true,
Expand All @@ -769,6 +770,7 @@ export class AssetRepository implements IAssetRepository {
ownerId: { in: options.userIds },
isVisible: true,
updatedAt: { gt: options.updatedAfter },
OR: [{ deletedAt: null }, { deletedAt: { not: null } }],
},
include: {
exifInfo: true,
Expand Down

0 comments on commit fb19328

Please sign in to comment.