suparisma 1.2.2 → 1.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +51 -2
- package/dist/generators/coreGenerator.js +200 -15
- package/dist/generators/hookGenerator.js +20 -2
- package/dist/generators/typeGenerator.js +55 -5
- package/dist/index.js +6 -1
- package/package.json +1 -1
- package/tmp/generated-test/hooks/useSuparismaAsset.ts +94 -0
- package/tmp/generated-test/hooks/useSuparismaChapter.ts +96 -0
- package/tmp/generated-test/hooks/useSuparismaCourse.ts +96 -0
- package/tmp/generated-test/hooks/useSuparismaDeviceSession.ts +94 -0
- package/tmp/generated-test/hooks/useSuparismaEnrollment.ts +92 -0
- package/tmp/generated-test/hooks/useSuparismaLesson.ts +96 -0
- package/tmp/generated-test/hooks/useSuparismaLessonPurchase.ts +92 -0
- package/tmp/generated-test/hooks/useSuparismaLessonQuestion.ts +96 -0
- package/tmp/generated-test/hooks/useSuparismaPayoutMethod.ts +96 -0
- package/tmp/generated-test/hooks/useSuparismaPayoutRequest.ts +96 -0
- package/tmp/generated-test/hooks/useSuparismaQuestionOption.ts +92 -0
- package/tmp/generated-test/hooks/useSuparismaSavedPaymentMethod.ts +96 -0
- package/tmp/generated-test/hooks/useSuparismaTeacherPayoutInfo.ts +96 -0
- package/tmp/generated-test/hooks/useSuparismaThing.ts +96 -0
- package/tmp/generated-test/hooks/useSuparismaUser.ts +96 -0
- package/tmp/generated-test/hooks/useSuparismaVideoNote.ts +96 -0
- package/tmp/generated-test/hooks/useSuparismaWallet.ts +96 -0
- package/tmp/generated-test/hooks/useSuparismaWalletTransaction.ts +96 -0
- package/tmp/generated-test/hooks/useSuparismaWatchProgress.ts +96 -0
- package/tmp/generated-test/index.ts +140 -0
- package/tmp/generated-test/types/AssetTypes.ts +485 -0
- package/tmp/generated-test/types/ChapterTypes.ts +488 -0
- package/tmp/generated-test/types/CourseTypes.ts +519 -0
- package/tmp/generated-test/types/DeviceSessionTypes.ts +489 -0
- package/tmp/generated-test/types/EnrollmentTypes.ts +495 -0
- package/tmp/generated-test/types/LessonPurchaseTypes.ts +490 -0
- package/tmp/generated-test/types/LessonQuestionTypes.ts +496 -0
- package/tmp/generated-test/types/LessonTypes.ts +517 -0
- package/tmp/generated-test/types/PayoutMethodTypes.ts +517 -0
- package/tmp/generated-test/types/PayoutRequestTypes.ts +528 -0
- package/tmp/generated-test/types/QuestionOptionTypes.ts +479 -0
- package/tmp/generated-test/types/SavedPaymentMethodTypes.ts +497 -0
- package/tmp/generated-test/types/TeacherPayoutInfoTypes.ts +480 -0
- package/tmp/generated-test/types/ThingTypes.ts +482 -0
- package/tmp/generated-test/types/UserTypes.ts +487 -0
- package/tmp/generated-test/types/VideoNoteTypes.ts +489 -0
- package/tmp/generated-test/types/WalletTransactionTypes.ts +505 -0
- package/tmp/generated-test/types/WalletTypes.ts +480 -0
- package/tmp/generated-test/types/WatchProgressTypes.ts +493 -0
- package/tmp/generated-test/utils/core.ts +2306 -0
- package/tmp/generated-test/utils/supabase-client.ts +17 -0
- package/tmp/generated-test2/hooks/useSuparismaAsset.ts +94 -0
- package/tmp/generated-test2/hooks/useSuparismaChapter.ts +96 -0
- package/tmp/generated-test2/hooks/useSuparismaCourse.ts +96 -0
- package/tmp/generated-test2/hooks/useSuparismaDeviceSession.ts +94 -0
- package/tmp/generated-test2/hooks/useSuparismaEnrollment.ts +92 -0
- package/tmp/generated-test2/hooks/useSuparismaLesson.ts +96 -0
- package/tmp/generated-test2/hooks/useSuparismaLessonPurchase.ts +92 -0
- package/tmp/generated-test2/hooks/useSuparismaLessonQuestion.ts +96 -0
- package/tmp/generated-test2/hooks/useSuparismaPayoutMethod.ts +96 -0
- package/tmp/generated-test2/hooks/useSuparismaPayoutRequest.ts +96 -0
- package/tmp/generated-test2/hooks/useSuparismaQuestionOption.ts +92 -0
- package/tmp/generated-test2/hooks/useSuparismaSavedPaymentMethod.ts +96 -0
- package/tmp/generated-test2/hooks/useSuparismaTeacherPayoutInfo.ts +96 -0
- package/tmp/generated-test2/hooks/useSuparismaThing.ts +96 -0
- package/tmp/generated-test2/hooks/useSuparismaUser.ts +96 -0
- package/tmp/generated-test2/hooks/useSuparismaVideoNote.ts +96 -0
- package/tmp/generated-test2/hooks/useSuparismaWallet.ts +96 -0
- package/tmp/generated-test2/hooks/useSuparismaWalletTransaction.ts +96 -0
- package/tmp/generated-test2/hooks/useSuparismaWatchProgress.ts +96 -0
- package/tmp/generated-test2/index.ts +140 -0
- package/tmp/generated-test2/types/AssetTypes.ts +485 -0
- package/tmp/generated-test2/types/ChapterTypes.ts +488 -0
- package/tmp/generated-test2/types/CourseTypes.ts +522 -0
- package/tmp/generated-test2/types/DeviceSessionTypes.ts +489 -0
- package/tmp/generated-test2/types/EnrollmentTypes.ts +495 -0
- package/tmp/generated-test2/types/LessonPurchaseTypes.ts +490 -0
- package/tmp/generated-test2/types/LessonQuestionTypes.ts +496 -0
- package/tmp/generated-test2/types/LessonTypes.ts +517 -0
- package/tmp/generated-test2/types/PayoutMethodTypes.ts +517 -0
- package/tmp/generated-test2/types/PayoutRequestTypes.ts +528 -0
- package/tmp/generated-test2/types/QuestionOptionTypes.ts +479 -0
- package/tmp/generated-test2/types/SavedPaymentMethodTypes.ts +497 -0
- package/tmp/generated-test2/types/TeacherPayoutInfoTypes.ts +480 -0
- package/tmp/generated-test2/types/ThingTypes.ts +482 -0
- package/tmp/generated-test2/types/UserTypes.ts +490 -0
- package/tmp/generated-test2/types/VideoNoteTypes.ts +489 -0
- package/tmp/generated-test2/types/WalletTransactionTypes.ts +505 -0
- package/tmp/generated-test2/types/WalletTypes.ts +480 -0
- package/tmp/generated-test2/types/WatchProgressTypes.ts +493 -0
- package/tmp/generated-test2/utils/core.ts +2306 -0
- package/tmp/generated-test2/utils/supabase-client.ts +17 -0
- package/tmp/generated-test3/hooks/useSuparismaAsset.ts +94 -0
- package/tmp/generated-test3/hooks/useSuparismaChapter.ts +98 -0
- package/tmp/generated-test3/hooks/useSuparismaCourse.ts +98 -0
- package/tmp/generated-test3/hooks/useSuparismaDeviceSession.ts +94 -0
- package/tmp/generated-test3/hooks/useSuparismaEnrollment.ts +94 -0
- package/tmp/generated-test3/hooks/useSuparismaLesson.ts +98 -0
- package/tmp/generated-test3/hooks/useSuparismaLessonPurchase.ts +94 -0
- package/tmp/generated-test3/hooks/useSuparismaLessonQuestion.ts +98 -0
- package/tmp/generated-test3/hooks/useSuparismaPayoutMethod.ts +96 -0
- package/tmp/generated-test3/hooks/useSuparismaPayoutRequest.ts +96 -0
- package/tmp/generated-test3/hooks/useSuparismaQuestionOption.ts +94 -0
- package/tmp/generated-test3/hooks/useSuparismaSavedPaymentMethod.ts +96 -0
- package/tmp/generated-test3/hooks/useSuparismaTeacherPayoutInfo.ts +98 -0
- package/tmp/generated-test3/hooks/useSuparismaThing.ts +96 -0
- package/tmp/generated-test3/hooks/useSuparismaUser.ts +98 -0
- package/tmp/generated-test3/hooks/useSuparismaVideoNote.ts +98 -0
- package/tmp/generated-test3/hooks/useSuparismaWallet.ts +98 -0
- package/tmp/generated-test3/hooks/useSuparismaWalletTransaction.ts +98 -0
- package/tmp/generated-test3/hooks/useSuparismaWatchProgress.ts +98 -0
- package/tmp/generated-test3/index.ts +140 -0
- package/tmp/generated-test3/types/AssetTypes.ts +485 -0
- package/tmp/generated-test3/types/ChapterTypes.ts +488 -0
- package/tmp/generated-test3/types/CourseTypes.ts +522 -0
- package/tmp/generated-test3/types/DeviceSessionTypes.ts +489 -0
- package/tmp/generated-test3/types/EnrollmentTypes.ts +495 -0
- package/tmp/generated-test3/types/LessonPurchaseTypes.ts +490 -0
- package/tmp/generated-test3/types/LessonQuestionTypes.ts +496 -0
- package/tmp/generated-test3/types/LessonTypes.ts +517 -0
- package/tmp/generated-test3/types/PayoutMethodTypes.ts +517 -0
- package/tmp/generated-test3/types/PayoutRequestTypes.ts +528 -0
- package/tmp/generated-test3/types/QuestionOptionTypes.ts +479 -0
- package/tmp/generated-test3/types/SavedPaymentMethodTypes.ts +497 -0
- package/tmp/generated-test3/types/TeacherPayoutInfoTypes.ts +480 -0
- package/tmp/generated-test3/types/ThingTypes.ts +482 -0
- package/tmp/generated-test3/types/UserTypes.ts +490 -0
- package/tmp/generated-test3/types/VideoNoteTypes.ts +489 -0
- package/tmp/generated-test3/types/WalletTransactionTypes.ts +505 -0
- package/tmp/generated-test3/types/WalletTypes.ts +480 -0
- package/tmp/generated-test3/types/WatchProgressTypes.ts +493 -0
- package/tmp/generated-test3/utils/core.ts +2316 -0
- package/tmp/generated-test3/utils/supabase-client.ts +17 -0
- package/tmp/prisma-test-schema-2.prisma +339 -0
- package/tmp/prisma-test-schema.prisma +317 -0
|
@@ -0,0 +1,519 @@
|
|
|
1
|
+
// THIS FILE IS AUTO-GENERATED - DO NOT EDIT DIRECTLY
|
|
2
|
+
// Edit the generator script instead
|
|
3
|
+
|
|
4
|
+
import type { Course } from '@prisma/client';
|
|
5
|
+
import type { ModelResult, SuparismaOptions, SearchQuery, SearchState, FilterOperators, IncludeValue } from '../utils/core';
|
|
6
|
+
import type { ChapterWithRelations, ChapterSelectInput } from './ChapterTypes';
|
|
7
|
+
import type { EnrollmentWithRelations, EnrollmentSelectInput } from './EnrollmentTypes';
|
|
8
|
+
import type { LessonPurchaseWithRelations, LessonPurchaseSelectInput } from './LessonPurchaseTypes';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Extended Course type that includes relation fields.
|
|
12
|
+
* This represents the complete shape of Course records returned from the database.
|
|
13
|
+
*/
|
|
14
|
+
export interface CourseWithRelations {
|
|
15
|
+
id: string;
|
|
16
|
+
title: string;
|
|
17
|
+
description?: string;
|
|
18
|
+
thumbnail?: string;
|
|
19
|
+
published: boolean;
|
|
20
|
+
teacherId: string;
|
|
21
|
+
createdAt: Date;
|
|
22
|
+
updatedAt: Date;
|
|
23
|
+
allowIndividualLessonPurchase: boolean;
|
|
24
|
+
blockScreenRecording: boolean;
|
|
25
|
+
maxDevices: number;
|
|
26
|
+
price: number;
|
|
27
|
+
pricingType: string;
|
|
28
|
+
defaultLessonPrice: number;
|
|
29
|
+
chapters?: ChapterWithRelations[];
|
|
30
|
+
enrollments?: EnrollmentWithRelations[];
|
|
31
|
+
purchases?: LessonPurchaseWithRelations[];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Input type for creating a new Course record.
|
|
36
|
+
* Fields with default values are optional and will be filled automatically if not provided.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* // Create a minimal course
|
|
40
|
+
* course.create({
|
|
41
|
+
* // Required fields only
|
|
42
|
+
* title: string,
|
|
43
|
+
* teacherId: string,
|
|
44
|
+
* });
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* // Create with optional fields
|
|
48
|
+
* course.create({
|
|
49
|
+
* // All fields including optional ones
|
|
50
|
+
* id?: string,
|
|
51
|
+
* title: string,
|
|
52
|
+
* description?: string,
|
|
53
|
+
* });
|
|
54
|
+
*/
|
|
55
|
+
export interface CourseCreateInput {
|
|
56
|
+
id?: string;
|
|
57
|
+
title: string;
|
|
58
|
+
description?: string;
|
|
59
|
+
thumbnail?: string;
|
|
60
|
+
published?: boolean;
|
|
61
|
+
teacherId: string;
|
|
62
|
+
allowIndividualLessonPurchase?: boolean;
|
|
63
|
+
blockScreenRecording?: boolean;
|
|
64
|
+
maxDevices?: number;
|
|
65
|
+
price?: number;
|
|
66
|
+
pricingType?: string;
|
|
67
|
+
defaultLessonPrice?: number;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Input type for updating an existing Course record.
|
|
72
|
+
* All fields are optional since you only need to specify the fields you want to change.
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* // Update a course's fields
|
|
76
|
+
* course.update({
|
|
77
|
+
* where: { id: "123" },
|
|
78
|
+
* data: {
|
|
79
|
+
* id?: string,
|
|
80
|
+
* title: string,
|
|
81
|
+
* }
|
|
82
|
+
* });
|
|
83
|
+
*/
|
|
84
|
+
export type CourseUpdateInput = Partial<CourseCreateInput>;
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Filter type for querying Course records.
|
|
88
|
+
* You can filter by any field in the model using equality or advanced filter operators.
|
|
89
|
+
* Supports OR and AND logical operations for complex queries.
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* // Basic filtering
|
|
93
|
+
* course.findMany({
|
|
94
|
+
* where: {
|
|
95
|
+
* id: "value",
|
|
96
|
+
* title: "value"
|
|
97
|
+
* }
|
|
98
|
+
* });
|
|
99
|
+
*
|
|
100
|
+
* @example
|
|
101
|
+
* // Advanced filtering
|
|
102
|
+
* course.findMany({
|
|
103
|
+
* where: {
|
|
104
|
+
* // Use advanced operators
|
|
105
|
+
* id: { contains: "partial" }
|
|
106
|
+
* }
|
|
107
|
+
* });
|
|
108
|
+
*
|
|
109
|
+
* @example
|
|
110
|
+
* // OR conditions - match ANY condition
|
|
111
|
+
* course.findMany({
|
|
112
|
+
* where: {
|
|
113
|
+
* OR: [
|
|
114
|
+
* { id: "value1" },
|
|
115
|
+
* { title: { contains: "value2" } }
|
|
116
|
+
* ]
|
|
117
|
+
* }
|
|
118
|
+
* });
|
|
119
|
+
*
|
|
120
|
+
* @example
|
|
121
|
+
* // AND conditions - match ALL conditions
|
|
122
|
+
* course.findMany({
|
|
123
|
+
* where: {
|
|
124
|
+
* AND: [
|
|
125
|
+
* { id: "value1" },
|
|
126
|
+
* { title: { gt: 100 } }
|
|
127
|
+
* ]
|
|
128
|
+
* }
|
|
129
|
+
* });
|
|
130
|
+
*
|
|
131
|
+
* @example
|
|
132
|
+
* // Complex nested logic
|
|
133
|
+
* course.findMany({
|
|
134
|
+
* where: {
|
|
135
|
+
* active: true, // Regular condition (implicit AND)
|
|
136
|
+
* OR: [
|
|
137
|
+
* { role: "admin" },
|
|
138
|
+
* { role: "moderator" }
|
|
139
|
+
* ]
|
|
140
|
+
* }
|
|
141
|
+
* });
|
|
142
|
+
*
|
|
143
|
+
* @example
|
|
144
|
+
* // Array filtering (for array fields)
|
|
145
|
+
* course.findMany({
|
|
146
|
+
* where: {
|
|
147
|
+
* // Array contains specific items
|
|
148
|
+
* chapters?: { has: ["item1", "item2"] }
|
|
149
|
+
* }
|
|
150
|
+
* });
|
|
151
|
+
*/
|
|
152
|
+
export type CourseWhereInput = {
|
|
153
|
+
id?: string | FilterOperators<string>;
|
|
154
|
+
title?: string | FilterOperators<string>;
|
|
155
|
+
description?: string | FilterOperators<string>;
|
|
156
|
+
thumbnail?: string | FilterOperators<string>;
|
|
157
|
+
published?: boolean | FilterOperators<boolean>;
|
|
158
|
+
teacherId?: string | FilterOperators<string>;
|
|
159
|
+
createdAt?: Date | FilterOperators<Date>;
|
|
160
|
+
updatedAt?: Date | FilterOperators<Date>;
|
|
161
|
+
allowIndividualLessonPurchase?: boolean | FilterOperators<boolean>;
|
|
162
|
+
blockScreenRecording?: boolean | FilterOperators<boolean>;
|
|
163
|
+
maxDevices?: number | FilterOperators<number>;
|
|
164
|
+
price?: number | FilterOperators<number>;
|
|
165
|
+
pricingType?: string | FilterOperators<string>;
|
|
166
|
+
defaultLessonPrice?: number | FilterOperators<number>;
|
|
167
|
+
} & {
|
|
168
|
+
/** Match ANY of the provided conditions */
|
|
169
|
+
OR?: CourseWhereInput[];
|
|
170
|
+
/** Match ALL of the provided conditions */
|
|
171
|
+
AND?: CourseWhereInput[];
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Unique identifier for finding a specific Course record.
|
|
176
|
+
* Usually uses the ID field but can be any field marked as @unique in the schema.
|
|
177
|
+
*
|
|
178
|
+
* @example
|
|
179
|
+
* // Find by ID
|
|
180
|
+
* course.findUnique({ id: "123" });
|
|
181
|
+
*
|
|
182
|
+
* @example
|
|
183
|
+
* // Delete by ID
|
|
184
|
+
* course.delete({ id: "123" });
|
|
185
|
+
*/
|
|
186
|
+
export type CourseWhereUniqueInput = {
|
|
187
|
+
id: string;
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Sort options for Course queries.
|
|
192
|
+
* Specify the field to sort by and the direction ('asc' or 'desc').
|
|
193
|
+
*
|
|
194
|
+
* @example
|
|
195
|
+
* // Sort by creation date, newest first
|
|
196
|
+
* course.findMany({
|
|
197
|
+
* orderBy: { created_at: 'desc' }
|
|
198
|
+
* });
|
|
199
|
+
*
|
|
200
|
+
* @example
|
|
201
|
+
* // Sort alphabetically
|
|
202
|
+
* course.findMany({
|
|
203
|
+
* orderBy: { name: 'asc' }
|
|
204
|
+
* });
|
|
205
|
+
*/
|
|
206
|
+
export type CourseOrderByInput = {
|
|
207
|
+
[key in keyof CourseSelectInput]?: 'asc' | 'desc';
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Select specific scalar fields to return from Course queries.
|
|
212
|
+
* Relation fields are intentionally excluded; use `include` for relations.
|
|
213
|
+
*/
|
|
214
|
+
export type CourseSelectInput = {
|
|
215
|
+
id?: boolean;
|
|
216
|
+
title?: boolean;
|
|
217
|
+
description?: boolean;
|
|
218
|
+
thumbnail?: boolean;
|
|
219
|
+
published?: boolean;
|
|
220
|
+
teacherId?: boolean;
|
|
221
|
+
createdAt?: boolean;
|
|
222
|
+
updatedAt?: boolean;
|
|
223
|
+
allowIndividualLessonPurchase?: boolean;
|
|
224
|
+
blockScreenRecording?: boolean;
|
|
225
|
+
maxDevices?: boolean;
|
|
226
|
+
price?: boolean;
|
|
227
|
+
pricingType?: boolean;
|
|
228
|
+
defaultLessonPrice?: boolean;
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Include related records when querying Course.
|
|
233
|
+
* Only real Prisma relation fields are allowed here.
|
|
234
|
+
*/
|
|
235
|
+
export type CourseIncludeInput = {
|
|
236
|
+
chapters?: IncludeValue | { select?: ChapterSelectInput };
|
|
237
|
+
enrollments?: IncludeValue | { select?: EnrollmentSelectInput };
|
|
238
|
+
purchases?: IncludeValue | { select?: LessonPurchaseSelectInput };
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* Result type for operations that return a single Course record.
|
|
243
|
+
*/
|
|
244
|
+
export type CourseSingleResult = ModelResult<CourseWithRelations>;
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* Result type for operations that return multiple Course records.
|
|
248
|
+
*/
|
|
249
|
+
export type CourseManyResult = ModelResult<CourseWithRelations[]>;
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* Configuration options for the Course hook.
|
|
253
|
+
* Includes where filters, ordering, pagination, and field selection.
|
|
254
|
+
*/
|
|
255
|
+
export type UseCourseOptions = SuparismaOptions<
|
|
256
|
+
CourseWhereInput,
|
|
257
|
+
CourseOrderByInput,
|
|
258
|
+
CourseSelectInput,
|
|
259
|
+
CourseIncludeInput
|
|
260
|
+
>;
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* The complete API for interacting with Course records.
|
|
264
|
+
* This interface defines all available operations and state properties.
|
|
265
|
+
*/
|
|
266
|
+
export interface CourseHookApi {
|
|
267
|
+
/**
|
|
268
|
+
* Current array of Course records.
|
|
269
|
+
* This is automatically updated when:
|
|
270
|
+
* - The initial data is loaded
|
|
271
|
+
* - Mutations are performed (create, update, delete)
|
|
272
|
+
* - Real-time updates are received from other clients
|
|
273
|
+
* - The refresh method is called
|
|
274
|
+
*
|
|
275
|
+
* @example
|
|
276
|
+
* // Render a list of course records
|
|
277
|
+
* const { data } = course;
|
|
278
|
+
* return (
|
|
279
|
+
* <ul>
|
|
280
|
+
* {data.map(item => (
|
|
281
|
+
* <li key={item.id}>{item.name}</li>
|
|
282
|
+
* ))}
|
|
283
|
+
* </ul>
|
|
284
|
+
* );
|
|
285
|
+
*/
|
|
286
|
+
data: CourseWithRelations[];
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* Error object if the last operation failed, null otherwise.
|
|
290
|
+
*
|
|
291
|
+
* @example
|
|
292
|
+
* // Handle potential errors
|
|
293
|
+
* const { error } = course;
|
|
294
|
+
* if (error) {
|
|
295
|
+
* return <div>Error: {error.message}</div>;
|
|
296
|
+
* }
|
|
297
|
+
*/
|
|
298
|
+
error: Error | null;
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* Boolean indicating if an operation is in progress.
|
|
302
|
+
*
|
|
303
|
+
* @example
|
|
304
|
+
* // Show loading state
|
|
305
|
+
* const { loading } = course;
|
|
306
|
+
* if (loading) {
|
|
307
|
+
* return <div>Loading...</div>;
|
|
308
|
+
* }
|
|
309
|
+
*/
|
|
310
|
+
loading: boolean;
|
|
311
|
+
|
|
312
|
+
/**
|
|
313
|
+
* The current count of records matching the filter criteria.
|
|
314
|
+
* This automatically updates with the data, including realtime updates.
|
|
315
|
+
* It always reflects the current length of the data array, respecting any filters.
|
|
316
|
+
*
|
|
317
|
+
* @example
|
|
318
|
+
* // Display the count in the UI
|
|
319
|
+
* const { count } = course;
|
|
320
|
+
* return <div>Total records: {count}</div>;
|
|
321
|
+
*/
|
|
322
|
+
count: number;
|
|
323
|
+
|
|
324
|
+
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* Find a single Course record by its unique identifier.
|
|
328
|
+
*
|
|
329
|
+
* @param where - The unique identifier to find the record by
|
|
330
|
+
* @returns A promise with the found record or error
|
|
331
|
+
*
|
|
332
|
+
* @example
|
|
333
|
+
* // Find course by ID
|
|
334
|
+
* const result = await course.findUnique({ id: "123" });
|
|
335
|
+
* if (result.data) {
|
|
336
|
+
* console.log("Found course:", result.data);
|
|
337
|
+
* }
|
|
338
|
+
*/
|
|
339
|
+
findUnique: (where: CourseWhereUniqueInput) => CourseSingleResult;
|
|
340
|
+
|
|
341
|
+
/**
|
|
342
|
+
* Find multiple Course records matching the filter criteria.
|
|
343
|
+
* Supports filtering, sorting, and pagination.
|
|
344
|
+
*
|
|
345
|
+
* @param params - Optional query parameters
|
|
346
|
+
* @returns A promise with the matching records or error
|
|
347
|
+
*
|
|
348
|
+
* @example
|
|
349
|
+
* // Get all course records
|
|
350
|
+
* const result = await course.findMany();
|
|
351
|
+
*
|
|
352
|
+
* @example
|
|
353
|
+
* // Filter and sort records
|
|
354
|
+
* const result = await course.findMany({
|
|
355
|
+
* where: { active: true },
|
|
356
|
+
* orderBy: { created_at: 'desc' },
|
|
357
|
+
* take: 10,
|
|
358
|
+
* skip: 0
|
|
359
|
+
* });
|
|
360
|
+
*/
|
|
361
|
+
findMany: (params?: {
|
|
362
|
+
where?: CourseWhereInput;
|
|
363
|
+
orderBy?: CourseOrderByInput;
|
|
364
|
+
take?: number;
|
|
365
|
+
skip?: number;
|
|
366
|
+
}) => CourseManyResult;
|
|
367
|
+
|
|
368
|
+
/**
|
|
369
|
+
* Find the first Course record matching the filter criteria.
|
|
370
|
+
*
|
|
371
|
+
* @param params - Optional query parameters
|
|
372
|
+
* @returns A promise with the first matching record or error
|
|
373
|
+
*
|
|
374
|
+
* @example
|
|
375
|
+
* // Find the first active course
|
|
376
|
+
* const result = await course.findFirst({
|
|
377
|
+
* where: { active: true }
|
|
378
|
+
* });
|
|
379
|
+
*
|
|
380
|
+
* @example
|
|
381
|
+
* // Find the oldest course
|
|
382
|
+
* const result = await course.findFirst({
|
|
383
|
+
* orderBy: { created_at: 'asc' }
|
|
384
|
+
* });
|
|
385
|
+
*/
|
|
386
|
+
findFirst: (params?: {
|
|
387
|
+
where?: CourseWhereInput;
|
|
388
|
+
orderBy?: CourseOrderByInput;
|
|
389
|
+
}) => CourseSingleResult;
|
|
390
|
+
|
|
391
|
+
/**
|
|
392
|
+
* Create a new Course record.
|
|
393
|
+
* Fields with default values are optional and will use their defaults if not provided.
|
|
394
|
+
*
|
|
395
|
+
* @param data - The data for the new record
|
|
396
|
+
* @returns A promise with the created record or error
|
|
397
|
+
*
|
|
398
|
+
* @example
|
|
399
|
+
* // Create a new course
|
|
400
|
+
* const result = await course.create({
|
|
401
|
+
* title: "value",
|
|
402
|
+
* teacherId: "value"
|
|
403
|
+
* });
|
|
404
|
+
*
|
|
405
|
+
* @example
|
|
406
|
+
* // Create with custom ID (overriding default)
|
|
407
|
+
* const result = await course.create({
|
|
408
|
+
* id: "custom-id",
|
|
409
|
+
* title: "value"
|
|
410
|
+
* });
|
|
411
|
+
*/
|
|
412
|
+
create: (data: CourseCreateInput) => CourseSingleResult;
|
|
413
|
+
|
|
414
|
+
/**
|
|
415
|
+
* Update an existing Course record.
|
|
416
|
+
*
|
|
417
|
+
* @param params - Object with the record identifier and fields to update
|
|
418
|
+
* @returns A promise with the updated record or error
|
|
419
|
+
*
|
|
420
|
+
* @example
|
|
421
|
+
* // Update a course's fields
|
|
422
|
+
* const result = await course.update({
|
|
423
|
+
* where: { id: "123" },
|
|
424
|
+
* data: {
|
|
425
|
+
* id?: "updated value",
|
|
426
|
+
* title: "updated value"
|
|
427
|
+
* }
|
|
428
|
+
* });
|
|
429
|
+
*/
|
|
430
|
+
update: (params: {
|
|
431
|
+
where: CourseWhereUniqueInput;
|
|
432
|
+
data: CourseUpdateInput;
|
|
433
|
+
}) => CourseSingleResult;
|
|
434
|
+
|
|
435
|
+
/**
|
|
436
|
+
* Delete a Course record by its unique identifier.
|
|
437
|
+
*
|
|
438
|
+
* @param where - The unique identifier of the record to delete
|
|
439
|
+
* @returns A promise with the deleted record or error
|
|
440
|
+
*
|
|
441
|
+
* @example
|
|
442
|
+
* // Delete a course by ID
|
|
443
|
+
* const result = await course.delete({ id: "123" });
|
|
444
|
+
* if (result.data) {
|
|
445
|
+
* console.log("Deleted course:", result.data);
|
|
446
|
+
* }
|
|
447
|
+
*/
|
|
448
|
+
delete: (where: CourseWhereUniqueInput) => CourseSingleResult;
|
|
449
|
+
|
|
450
|
+
/**
|
|
451
|
+
* Delete multiple Course records matching the filter criteria.
|
|
452
|
+
*
|
|
453
|
+
* @param params - Optional filter parameters
|
|
454
|
+
* @returns A promise with the count of deleted records or error
|
|
455
|
+
*
|
|
456
|
+
* @example
|
|
457
|
+
* // Delete all inactive course records
|
|
458
|
+
* const result = await course.deleteMany({
|
|
459
|
+
* where: { active: false }
|
|
460
|
+
* });
|
|
461
|
+
* console.log(`Deleted ${result.count} records`);
|
|
462
|
+
*
|
|
463
|
+
* @example
|
|
464
|
+
* // Delete all course records (use with caution!)
|
|
465
|
+
* const result = await course.deleteMany();
|
|
466
|
+
*/
|
|
467
|
+
deleteMany: (params?: {
|
|
468
|
+
where?: CourseWhereInput;
|
|
469
|
+
}) => Promise<{ count: number; error: Error | null }>;
|
|
470
|
+
|
|
471
|
+
/**
|
|
472
|
+
* Create a record if it doesn't exist, or update it if it does.
|
|
473
|
+
*
|
|
474
|
+
* @param params - Object with the identifier, update data, and create data
|
|
475
|
+
* @returns A promise with the created or updated record or error
|
|
476
|
+
*
|
|
477
|
+
* @example
|
|
478
|
+
* // Upsert a course by ID
|
|
479
|
+
* const result = await course.upsert({
|
|
480
|
+
* where: { id: "123" },
|
|
481
|
+
* update: { name: "Updated Name" },
|
|
482
|
+
* create: {
|
|
483
|
+
* id: "123",
|
|
484
|
+
* name: "New Name",
|
|
485
|
+
* title: "value"
|
|
486
|
+
* }
|
|
487
|
+
* });
|
|
488
|
+
*/
|
|
489
|
+
upsert: (params: {
|
|
490
|
+
where: CourseWhereUniqueInput;
|
|
491
|
+
update: CourseUpdateInput;
|
|
492
|
+
create: CourseCreateInput;
|
|
493
|
+
}) => CourseSingleResult;
|
|
494
|
+
|
|
495
|
+
/**
|
|
496
|
+
* Manually refresh the data with current filter settings.
|
|
497
|
+
* Useful after external operations or when realtime is disabled.
|
|
498
|
+
*
|
|
499
|
+
* @param params - Optional override parameters for this specific refresh
|
|
500
|
+
* @returns A promise with the refreshed data or error
|
|
501
|
+
*
|
|
502
|
+
* @example
|
|
503
|
+
* // Refresh with current filter settings
|
|
504
|
+
* await course.refresh();
|
|
505
|
+
*
|
|
506
|
+
* @example
|
|
507
|
+
* // Refresh with different filters for this call only
|
|
508
|
+
* await course.refresh({
|
|
509
|
+
* where: { active: true },
|
|
510
|
+
* orderBy: { name: 'asc' }
|
|
511
|
+
* });
|
|
512
|
+
*/
|
|
513
|
+
refresh: (params?: {
|
|
514
|
+
where?: CourseWhereInput;
|
|
515
|
+
orderBy?: CourseOrderByInput;
|
|
516
|
+
take?: number;
|
|
517
|
+
skip?: number;
|
|
518
|
+
}) => CourseManyResult;
|
|
519
|
+
}
|