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