@hazeljs/prisma 0.7.8 → 0.8.0
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 +25 -19
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -21,11 +21,11 @@ Repository pattern, `@Repository` decorator, DI integration. Full CRUD from your
|
|
|
21
21
|
|
|
22
22
|
## Decorator Convention
|
|
23
23
|
|
|
24
|
-
| Class type
|
|
25
|
-
|
|
24
|
+
| Class type | Correct decorator |
|
|
25
|
+
| ------------------------------------- | --------------------------------------------------------- |
|
|
26
26
|
| Repository (`extends BaseRepository`) | `@Repository({ model: '...' })` — implies `@Injectable()` |
|
|
27
|
-
| Service (business logic)
|
|
28
|
-
| Controller
|
|
27
|
+
| Service (business logic) | `@Service()` |
|
|
28
|
+
| Controller | `@Controller(...)` |
|
|
29
29
|
|
|
30
30
|
## Installation
|
|
31
31
|
|
|
@@ -136,9 +136,7 @@ import { InjectRepository } from '@hazeljs/prisma';
|
|
|
136
136
|
|
|
137
137
|
@Service()
|
|
138
138
|
export class UserService {
|
|
139
|
-
constructor(
|
|
140
|
-
@InjectRepository() private readonly userRepository: UserRepository,
|
|
141
|
-
) {}
|
|
139
|
+
constructor(@InjectRepository() private readonly userRepository: UserRepository) {}
|
|
142
140
|
|
|
143
141
|
async create(data: { email: string; name: string }) {
|
|
144
142
|
return this.userRepository.create(data);
|
|
@@ -227,7 +225,7 @@ export class OrderService {
|
|
|
227
225
|
constructor(
|
|
228
226
|
private readonly orderRepository: OrderRepository,
|
|
229
227
|
private readonly inventoryRepository: InventoryRepository,
|
|
230
|
-
private readonly prisma: PrismaService
|
|
228
|
+
private readonly prisma: PrismaService
|
|
231
229
|
) {}
|
|
232
230
|
|
|
233
231
|
async createOrder(userId: string, items: OrderItem[]) {
|
|
@@ -308,19 +306,24 @@ export class ProductRepository extends BaseRepository<Product> {
|
|
|
308
306
|
super(prisma, 'product');
|
|
309
307
|
}
|
|
310
308
|
|
|
311
|
-
async search(
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
309
|
+
async search(
|
|
310
|
+
query: string,
|
|
311
|
+
filters: {
|
|
312
|
+
category?: string;
|
|
313
|
+
minPrice?: number;
|
|
314
|
+
maxPrice?: number;
|
|
315
|
+
inStock?: boolean;
|
|
316
|
+
}
|
|
317
|
+
) {
|
|
317
318
|
return this.prisma.product.findMany({
|
|
318
319
|
where: {
|
|
319
320
|
AND: [
|
|
320
|
-
{
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
321
|
+
{
|
|
322
|
+
OR: [
|
|
323
|
+
{ name: { contains: query, mode: 'insensitive' } },
|
|
324
|
+
{ description: { contains: query, mode: 'insensitive' } },
|
|
325
|
+
],
|
|
326
|
+
},
|
|
324
327
|
filters.category ? { category: filters.category } : {},
|
|
325
328
|
filters.minPrice ? { price: { gte: filters.minPrice } } : {},
|
|
326
329
|
filters.maxPrice ? { price: { lte: filters.maxPrice } } : {},
|
|
@@ -417,7 +420,10 @@ async function main() {
|
|
|
417
420
|
}
|
|
418
421
|
|
|
419
422
|
main()
|
|
420
|
-
.catch((e) => {
|
|
423
|
+
.catch((e) => {
|
|
424
|
+
console.error(e);
|
|
425
|
+
process.exit(1);
|
|
426
|
+
})
|
|
421
427
|
.finally(() => prisma.$disconnect());
|
|
422
428
|
```
|
|
423
429
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hazeljs/prisma",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "Prisma ORM integration for HazelJS framework",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -50,5 +50,5 @@
|
|
|
50
50
|
"peerDependencies": {
|
|
51
51
|
"@hazeljs/core": ">=0.2.0-beta.0"
|
|
52
52
|
},
|
|
53
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "e0ed98ca074dd4f7472816d3c32ef576900dcca6"
|
|
54
54
|
}
|