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);
}

View File

@@ -0,0 +1,11 @@
import { COL_LESSON_TYPES } from '@/constants';
import type { RecordModel } from 'pocketbase';
import { pb } from '@/lib/pb';
import type { CreateForm } from '@/components/dashboard/lesson_type/types';
// import type { CreateForm } from '@/components/dashboard/lesson_type/interfaces.ts.del';
export default function createLessonType(data: CreateForm): Promise<RecordModel> {
return pb.collection(COL_LESSON_TYPES).create(data);
}

View File

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

View File

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

View File

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

View File

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

View File

@@ -0,0 +1,19 @@
# PROMPT
with reference to `src/db/LessonTypes/DBLessonTypes.tsx`, clone and modify to fit `DBLessonCategories.tsx` thanks.
---
# PROMPT
from `LessonTypes`, clone and modify to fit `LessonCategories` (e.g. CRUD) thanks.
---
# PROMPT
with reference to
- `/home/logic/_wsl_workspace/001_github_ws/lettersoup-online-ws/lettersoup-online/project/001_documentation/Requirements/REQ0006/schema.dbml`
- `/home/logic/_wsl_workspace/001_github_ws/lettersoup-online-ws/lettersoup-online/project/002_source/cms/src/db/LessonTypes`
draft `UserMeta` thanks