update init db api,

This commit is contained in:
louiscklaw
2025-04-18 05:21:43 +08:00
parent be0ddc5323
commit 44abd70563
12 changed files with 108 additions and 0 deletions

View File

@@ -0,0 +1,9 @@
import { COL_LESSON_CATEGORIES } from '@/constants';
import type { RecordModel } from 'pocketbase';
import { pb } from '@/lib/pb';
import type { CreateForm } from '@/components/dashboard/lesson_category/types';
export default function createLessonCategory(data: CreateForm): Promise<RecordModel> {
return pb.collection(COL_LESSON_CATEGORIES).create(data);
}

View File

@@ -0,0 +1,7 @@
import { COL_LESSON_CATEGORIES } from '@/constants';
import { pb } from '@/lib/pb';
export default function deleteLessonCategory(id: string): Promise<boolean> {
return pb.collection(COL_LESSON_CATEGORIES).delete(id);
}

View File

@@ -0,0 +1,8 @@
import { COL_LESSON_CATEGORIES } from '@/constants';
import type { RecordModel } from 'pocketbase';
import { pb } from '@/lib/pb';
export default function getAllLessonCategories(): Promise<RecordModel[]> {
return pb.collection(COL_LESSON_CATEGORIES).getFullList();
}

View File

@@ -0,0 +1,8 @@
import { COL_LESSON_CATEGORIES } from '@/constants';
import type { RecordModel } from 'pocketbase';
import { pb } from '@/lib/pb';
export default function getLessonCategoryById(id: string): Promise<RecordModel> {
return pb.collection(COL_LESSON_CATEGORIES).getOne(id);
}

View File

@@ -0,0 +1,5 @@
function Helloworld(): string {
return 'helloworld';
}
export { Helloworld };

View File

@@ -0,0 +1,9 @@
import { COL_LESSON_CATEGORIES } from '@/constants';
import type { RecordModel } from 'pocketbase';
import { pb } from '@/lib/pb';
import type { CreateForm } from '@/components/dashboard/lesson_category/types';
export default function updateLessonCategory(id: string, data: CreateForm): Promise<RecordModel> {
return pb.collection(COL_LESSON_CATEGORIES).update(id, data);
}