share api, queries, permissions, migration, entity lib
This commit is contained in:
1 parent
a270b0afea
commit
29f2c7b7d4
11 files changed
+256
-23
No files matched your search
@@ -2,6 +2,7 @@ export * from './link';
|
||||
export * from './pixel';
|
||||
export * from './report';
|
||||
export * from './segment';
|
||||
export * from './share';
|
||||
export * from './team';
|
||||
export * from './teamUser';
|
||||
export * from './user';
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
import type { Prisma } from '@/generated/prisma/client';
|
||||
import prisma from '@/lib/prisma';
|
||||
|
||||
export async function findShare(criteria: Prisma.ShareFindUniqueArgs) {
|
||||
return prisma.client.share.findUnique(criteria);
|
||||
}
|
||||
|
||||
export async function getShare(entityId: string) {
|
||||
return findShare({
|
||||
where: {
|
||||
id: entityId,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export async function getShareByCode(slug: string) {
|
||||
return findShare({
|
||||
where: {
|
||||
slug,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export async function createShare(
|
||||
data: Prisma.ShareCreateInput | Prisma.ShareUncheckedCreateInput,
|
||||
) {
|
||||
return prisma.client.share.create({
|
||||
data,
|
||||
});
|
||||
}
|
||||
|
||||
export async function updateShare(
|
||||
shareId: string,
|
||||
data: Prisma.ShareUpdateInput | Prisma.ShareUncheckedUpdateInput,
|
||||
) {
|
||||
return prisma.client.share.update({
|
||||
where: {
|
||||
id: shareId,
|
||||
},
|
||||
data,
|
||||
});
|
||||
}
|
||||
|
||||
export async function deleteShare(shareId: string) {
|
||||
return prisma.client.share.delete({ where: { id: shareId } });
|
||||
}
|
||||
@@ -16,15 +16,6 @@ export async function getWebsite(websiteId: string) {
|
||||
});
|
||||
}
|
||||
|
||||
export async function getSharedWebsite(shareId: string) {
|
||||
return findWebsite({
|
||||
where: {
|
||||
shareId,
|
||||
deletedAt: null,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export async function getWebsites(criteria: Prisma.WebsiteFindManyArgs, filters: QueryFilters) {
|
||||
const { search } = filters;
|
||||
const { getSearchParameters, pagedQuery } = prisma;
|
||||
|
||||
Reference in new issue
Block a user