mirror of
https://github.com/umami-software/umami.git
synced 2026-02-06 21:57:16 +01:00
share api, queries, permissions, migration, entity lib
Some checks are pending
Node.js CI / build (push) Waiting to run
Some checks are pending
Node.js CI / build (push) Waiting to run
This commit is contained in:
parent
a270b0afea
commit
29f2c7b7d4
11 changed files with 256 additions and 23 deletions
|
|
@ -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';
|
||||
|
|
|
|||
46
src/queries/prisma/share.ts
Normal file
46
src/queries/prisma/share.ts
Normal file
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue