You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -175,44 +175,44 @@ A similar functionality as described [above](recipes/async-local-storage#custom-
175
175
},
176
176
}),
177
177
],
178
-
providers: [CatService],
179
-
controllers: [CatController],
178
+
providers: [CatsService],
179
+
controllers: [CatsController],
180
180
})
181
181
exportclassAppModule {}
182
182
```
183
183
184
184
2. And then can use the `ClsService` to access the store values.
185
185
186
186
```ts
187
-
@@filename(cat.service)
187
+
@@filename(cats.service)
188
188
@Injectable()
189
-
exportclassCatService {
189
+
exportclassCatsService {
190
190
constructor(
191
191
// We can inject the provided ClsService instance,
192
192
privatereadonlycls:ClsService,
193
-
privatereadonlycatRepository:CatRepository,
193
+
privatereadonlycatsRepository:CatsRepository,
194
194
) {}
195
195
196
196
getCatForUser() {
197
197
// and use the "get" method to retrieve any stored value.
198
198
const userId =this.cls.get('userId');
199
-
returnthis.catRepository.getForUser(userId);
199
+
returnthis.catsRepository.getForUser(userId);
200
200
}
201
201
}
202
202
@@switch
203
203
@Injectable()
204
-
@Dependencies(AsyncLocalStorage, CatRepository)
205
-
exportclassCatService {
206
-
constructor(cls, catRepository) {
204
+
@Dependencies(AsyncLocalStorage, CatsRepository)
205
+
exportclassCatsService {
206
+
constructor(cls, catsRepository) {
207
207
// We can inject the provided ClsService instance,
208
208
this.cls=cls
209
-
this.catRepository=catRepository
209
+
this.catsRepository=catsRepository
210
210
}
211
211
212
212
getCatForUser() {
213
213
// and use the "get" method to retrieve any stored value.
214
214
const userId =this.cls.get('userId');
215
-
returnthis.catRepository.getForUser(userId);
215
+
returnthis.catsRepository.getForUser(userId);
216
216
}
217
217
}
218
218
```
@@ -233,19 +233,19 @@ Since the `ClsService` is just another injectable provider, it can be entirely m
233
233
However, in certain integration tests, we might still want to use the real `ClsService` implementation. In that case, we will need to wrap the context-aware piece of code with a call to `ClsService#run` or `ClsService#runWith`.
Copy file name to clipboardExpand all lines: content/recipes/prisma.md
+7-7
Original file line number
Diff line number
Diff line change
@@ -296,7 +296,7 @@ import { PrismaService } from './prisma.service';
296
296
import { User, Prisma } from'@prisma/client';
297
297
298
298
@Injectable()
299
-
exportclassUserService {
299
+
exportclassUsersService {
300
300
constructor(privateprisma:PrismaService) {}
301
301
302
302
async user(
@@ -361,7 +361,7 @@ import { PrismaService } from './prisma.service';
361
361
import { Post, Prisma } from'@prisma/client';
362
362
363
363
@Injectable()
364
-
exportclassPostService {
364
+
exportclassPostsService {
365
365
constructor(privateprisma:PrismaService) {}
366
366
367
367
async post(
@@ -414,7 +414,7 @@ export class PostService {
414
414
}
415
415
```
416
416
417
-
Your `UserService` and `PostService` currently wrap the CRUD queries that are available in Prisma Client. In a real world application, the service would also be the place to add business logic to your application. For example, you could have a method called `updatePassword` inside the `UserService` that would be responsible for updating the password of a user.
417
+
Your `UsersService` and `PostsService` currently wrap the CRUD queries that are available in Prisma Client. In a real world application, the service would also be the place to add business logic to your application. For example, you could have a method called `updatePassword` inside the `UsersService` that would be responsible for updating the password of a user.
418
418
419
419
Remember to register the new services in the app module.
0 commit comments