mirror of
https://github.com/umami-software/umami.git
synced 2026-02-08 06:37:18 +01:00
Boards components.
Some checks failed
Node.js CI / build (postgresql, 18.18, 10) (push) Has been cancelled
Some checks failed
Node.js CI / build (postgresql, 18.18, 10) (push) Has been cancelled
This commit is contained in:
parent
7edddf15a7
commit
a39ebffd8b
20 changed files with 450 additions and 33 deletions
61
src/queries/prisma/board.ts
Normal file
61
src/queries/prisma/board.ts
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
import type { Prisma } from '@/generated/prisma/client';
|
||||
import prisma from '@/lib/prisma';
|
||||
import type { QueryFilters } from '@/lib/types';
|
||||
|
||||
export async function findBoard(criteria: Prisma.BoardFindUniqueArgs) {
|
||||
return prisma.client.board.findUnique(criteria);
|
||||
}
|
||||
|
||||
export async function getBoard(boardId: string) {
|
||||
return findBoard({
|
||||
where: {
|
||||
id: boardId,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export async function getBoards(criteria: Prisma.BoardFindManyArgs, filters: QueryFilters = {}) {
|
||||
const { search } = filters;
|
||||
const { getSearchParameters, pagedQuery } = prisma;
|
||||
|
||||
const where: Prisma.BoardWhereInput = {
|
||||
...criteria.where,
|
||||
...getSearchParameters(search, [{ name: 'contains' }, { description: 'contains' }]),
|
||||
};
|
||||
|
||||
return pagedQuery('board', { ...criteria, where }, filters);
|
||||
}
|
||||
|
||||
export async function getUserBoards(userId: string, filters?: QueryFilters) {
|
||||
return getBoards(
|
||||
{
|
||||
where: {
|
||||
userId,
|
||||
},
|
||||
},
|
||||
filters,
|
||||
);
|
||||
}
|
||||
|
||||
export async function getTeamBoards(teamId: string, filters?: QueryFilters) {
|
||||
return getBoards(
|
||||
{
|
||||
where: {
|
||||
teamId,
|
||||
},
|
||||
},
|
||||
filters,
|
||||
);
|
||||
}
|
||||
|
||||
export async function createBoard(data: Prisma.BoardUncheckedCreateInput) {
|
||||
return prisma.client.board.create({ data });
|
||||
}
|
||||
|
||||
export async function updateBoard(boardId: string, data: any) {
|
||||
return prisma.client.board.update({ where: { id: boardId }, data });
|
||||
}
|
||||
|
||||
export async function deleteBoard(boardId: string) {
|
||||
return prisma.client.board.delete({ where: { id: boardId } });
|
||||
}
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
export * from './board';
|
||||
export * from './link';
|
||||
export * from './pixel';
|
||||
export * from './report';
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue