@@ -273,19 +273,15 @@ Still inside the `src` directory, create a new file called `user.service.ts` and
273
273
import { Injectable } from ' @nestjs/common' ;
274
274
import { PrismaService } from ' ./prisma.service' ;
275
275
import {
276
- UserUpdateInput ,
277
276
User ,
278
- UserCreateInput ,
279
- UserWhereUniqueInput ,
280
- UserWhereInput ,
281
- UserOrderByInput ,
277
+ Prisma
282
278
} from ' @prisma/client' ;
283
279
284
280
@Injectable ()
285
281
export class UserService {
286
282
constructor (private prisma : PrismaService ) {}
287
283
288
- async user(userWhereUniqueInput : UserWhereUniqueInput ): Promise <User | null > {
284
+ async user(userWhereUniqueInput : Prisma . UserWhereUniqueInput ): Promise <User | null > {
289
285
return this .prisma .user .findUnique ({
290
286
where: userWhereUniqueInput ,
291
287
});
@@ -294,9 +290,9 @@ export class UserService {
294
290
async users(params : {
295
291
skip? : number ;
296
292
take? : number ;
297
- cursor? : UserWhereUniqueInput ;
298
- where? : UserWhereInput ;
299
- orderBy? : UserOrderByInput ;
293
+ cursor? : Prisma . UserWhereUniqueInput ;
294
+ where? : Prisma . UserWhereInput ;
295
+ orderBy? : Prisma . UserOrderByInput ;
300
296
}): Promise <User []> {
301
297
const { skip, take, cursor, where, orderBy } = params ;
302
298
return this .prisma .user .findMany ({
@@ -308,15 +304,15 @@ export class UserService {
308
304
});
309
305
}
310
306
311
- async createUser(data : UserCreateInput ): Promise <User > {
307
+ async createUser(data : Prisma . UserCreateInput ): Promise <User > {
312
308
return this .prisma .user .create ({
313
309
data ,
314
310
});
315
311
}
316
312
317
313
async updateUser(params : {
318
- where: UserWhereUniqueInput ;
319
- data: UserUpdateInput ;
314
+ where: Prisma . UserWhereUniqueInput ;
315
+ data: Prisma . UserUpdateInput ;
320
316
}): Promise <User > {
321
317
const { where, data } = params ;
322
318
return this .prisma .user .update ({
@@ -325,7 +321,7 @@ export class UserService {
325
321
});
326
322
}
327
323
328
- async deleteUser(where : UserWhereUniqueInput ): Promise <User > {
324
+ async deleteUser(where : Prisma . UserWhereUniqueInput ): Promise <User > {
329
325
return this .prisma .user .delete ({
330
326
where ,
331
327
});
@@ -343,19 +339,15 @@ Still inside the `src` directory, create a new file called `post.service.ts` and
343
339
import { Injectable } from ' @nestjs/common' ;
344
340
import { PrismaService } from ' ./prisma.service' ;
345
341
import {
346
- PostUpdateInput ,
347
342
Post ,
348
- PostCreateInput ,
349
- PostWhereUniqueInput ,
350
- PostWhereInput ,
351
- PostOrderByInput ,
343
+ Prisma ,
352
344
} from ' @prisma/client' ;
353
345
354
346
@Injectable ()
355
347
export class PostService {
356
348
constructor (private prisma : PrismaService ) {}
357
349
358
- async post(postWhereUniqueInput : PostWhereUniqueInput ): Promise <Post | null > {
350
+ async post(postWhereUniqueInput : Prisma . PostWhereUniqueInput ): Promise <Post | null > {
359
351
return this .prisma .post .findUnique ({
360
352
where: postWhereUniqueInput ,
361
353
});
@@ -364,9 +356,9 @@ export class PostService {
364
356
async posts(params : {
365
357
skip? : number ;
366
358
take? : number ;
367
- cursor? : PostWhereUniqueInput ;
368
- where? : PostWhereInput ;
369
- orderBy? : PostOrderByInput ;
359
+ cursor? : Prisma . PostWhereUniqueInput ;
360
+ where? : Prisma . PostWhereInput ;
361
+ orderBy? : Prisma . PostOrderByInput ;
370
362
}): Promise <Post []> {
371
363
const { skip, take, cursor, where, orderBy } = params ;
372
364
return this .prisma .post .findMany ({
@@ -378,15 +370,15 @@ export class PostService {
378
370
});
379
371
}
380
372
381
- async createPost(data : PostCreateInput ): Promise <Post > {
373
+ async createPost(data : Prisma . PostCreateInput ): Promise <Post > {
382
374
return this .prisma .post .create ({
383
375
data ,
384
376
});
385
377
}
386
378
387
379
async updatePost(params : {
388
- where: PostWhereUniqueInput ;
389
- data: PostUpdateInput ;
380
+ where: Prisma . PostWhereUniqueInput ;
381
+ data: Prisma . PostUpdateInput ;
390
382
}): Promise <Post > {
391
383
const { data, where } = params ;
392
384
return this .prisma .post .update ({
@@ -395,7 +387,7 @@ export class PostService {
395
387
});
396
388
}
397
389
398
- async deletePost(where : PostWhereUniqueInput ): Promise <Post > {
390
+ async deletePost(where : Prisma . PostWhereUniqueInput ): Promise <Post > {
399
391
return this .prisma .post .delete ({
400
392
where ,
401
393
});
0 commit comments