vsrepo 1.2.1 → 1.2.3
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 +66 -19
- package/VSRepository/VSRepository.d.ts +879 -834
- package/VSRepository/VSRepository.js +31 -19
- package/package.json +4 -4
|
@@ -101,7 +101,23 @@ export class VSRepository {
|
|
|
101
101
|
const whereParams = [];
|
|
102
102
|
const otherParams = [];
|
|
103
103
|
|
|
104
|
-
if(keyToMap
|
|
104
|
+
if(keyToMap === 'aggregate') {
|
|
105
|
+
keyToMapReplaced = keyToMap.replace('aggregate', '')
|
|
106
|
+
ignoreSelect = true;
|
|
107
|
+
ignoreWhere = true;
|
|
108
|
+
method = 'aggregate';
|
|
109
|
+
prismaArgsIndex = 0;
|
|
110
|
+
otherParams.push('prismaArgs');
|
|
111
|
+
argsCount++;
|
|
112
|
+
} else if(keyToMap === 'groupBy') {
|
|
113
|
+
keyToMapReplaced = keyToMap.replace('groupBy', '')
|
|
114
|
+
ignoreSelect = true;
|
|
115
|
+
ignoreWhere = true;
|
|
116
|
+
method = 'groupBy';
|
|
117
|
+
prismaArgsIndex = 0;
|
|
118
|
+
otherParams.push('prismaArgs');
|
|
119
|
+
argsCount++;
|
|
120
|
+
} else if(keyToMap.startsWith('findUniqueOrThrowBy')) {
|
|
105
121
|
keyToMapReplaced = keyToMap.replace('findUniqueOrThrowBy', '');
|
|
106
122
|
method = 'findUniqueOrThrow';
|
|
107
123
|
} else if(keyToMap.startsWith('findUniqueBy')) {
|
|
@@ -244,22 +260,6 @@ export class VSRepository {
|
|
|
244
260
|
keyToMapReplaced = keyToMap.replace('findBy', '');
|
|
245
261
|
ignoreOrderByAndPagination = false;
|
|
246
262
|
method = methods[originalKey].fbMode === 'one' ? 'findFirst' : 'findMany';
|
|
247
|
-
} else if(keyToMap === 'aggregate') {
|
|
248
|
-
keyToMapReplaced = keyToMap.replace('aggregate', '')
|
|
249
|
-
ignoreSelect = true;
|
|
250
|
-
ignoreWhere = true;
|
|
251
|
-
method = 'aggregate';
|
|
252
|
-
prismaArgsIndex = 0;
|
|
253
|
-
otherParams.push('prismaArgs');
|
|
254
|
-
argsCount++;
|
|
255
|
-
} else if(keyToMap === 'groupBy') {
|
|
256
|
-
keyToMapReplaced = keyToMap.replace('groupBy', '')
|
|
257
|
-
ignoreSelect = true;
|
|
258
|
-
ignoreWhere = true;
|
|
259
|
-
method = 'groupBy';
|
|
260
|
-
prismaArgsIndex = 0;
|
|
261
|
-
otherParams.push('prismaArgs');
|
|
262
|
-
argsCount++;
|
|
263
263
|
} else {
|
|
264
264
|
throw new VSRepoBuildError(`[VSRepository] (build) Unknown method: ${keyToMap}.`);
|
|
265
265
|
}
|
|
@@ -361,7 +361,15 @@ export class VSRepository {
|
|
|
361
361
|
keySplitedAnd = keySplitedAnd.replace('Optional', '');
|
|
362
362
|
}
|
|
363
363
|
|
|
364
|
-
if(keySplitedAnd.includes('
|
|
364
|
+
if(keySplitedAnd.includes('NotBetween')){
|
|
365
|
+
buildedWhere.pushProperty = 'not';
|
|
366
|
+
buildedWhere.betweenMode = true;
|
|
367
|
+
keySplitedAnd = keySplitedAnd.replace('NotBetween', '')
|
|
368
|
+
} else if(keySplitedAnd.includes('Between')){
|
|
369
|
+
buildedWhere.pushProperty = '$$$';
|
|
370
|
+
buildedWhere.betweenMode = true;
|
|
371
|
+
keySplitedAnd = keySplitedAnd.replace('Between', '')
|
|
372
|
+
} else if(keySplitedAnd.includes('NotStartsWith')){
|
|
365
373
|
buildedWhere.pushProperty = 'not.startsWith';
|
|
366
374
|
keySplitedAnd = keySplitedAnd.replace('NotStartsWith', '')
|
|
367
375
|
} else if(keySplitedAnd.includes('StartsWith')){
|
|
@@ -562,7 +570,7 @@ export class VSRepository {
|
|
|
562
570
|
}
|
|
563
571
|
|
|
564
572
|
whereParams.push(argName);
|
|
565
|
-
return { context, otherProps, argName, autoVal: arg.autoInjectVal };
|
|
573
|
+
return { context, otherProps, argName, autoVal: arg.autoInjectVal, betweenMode: arg.betweenMode };
|
|
566
574
|
});
|
|
567
575
|
if(showWorking) {
|
|
568
576
|
console.log(`[VSRepository] (build) Where object resolved to ${keyToMap}:\n`, JSON.stringify(whereResolved, null, 2));
|
|
@@ -663,6 +671,10 @@ export class VSRepository {
|
|
|
663
671
|
if(currentWhereRslvd.autoVal !== undefined) {
|
|
664
672
|
current[context[i]] = currentWhereRslvd.autoVal;
|
|
665
673
|
adjust++
|
|
674
|
+
} else if (currentWhereRslvd.betweenMode && args[j - adjust] !== undefined) {
|
|
675
|
+
current[context[i]] = {};
|
|
676
|
+
current[context[i]]["gte"] = args[j - adjust][0];
|
|
677
|
+
current[context[i]]["lte"] = args[j - adjust][1];
|
|
666
678
|
} else {
|
|
667
679
|
current[context[i]] = args[j - adjust];
|
|
668
680
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vsrepo",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.3",
|
|
4
4
|
"description": "Uma biblioteca de repository pattern para Prisma",
|
|
5
5
|
"homepage": "https://github.com/jaobrabo123/VSRepository#readme",
|
|
6
6
|
"repository": {
|
|
@@ -38,8 +38,7 @@
|
|
|
38
38
|
"node": ">=18"
|
|
39
39
|
},
|
|
40
40
|
"scripts": {
|
|
41
|
-
"vsrepo": "node ./scripts/configure-prisma-import.mjs"
|
|
42
|
-
"configure:prisma-import": "node ./scripts/configure-prisma-import.mjs"
|
|
41
|
+
"vsrepo": "node ./scripts/configure-prisma-import.mjs"
|
|
43
42
|
},
|
|
44
43
|
"keywords": [
|
|
45
44
|
"prisma",
|
|
@@ -47,7 +46,8 @@
|
|
|
47
46
|
"orm",
|
|
48
47
|
"typescript",
|
|
49
48
|
"vsrepo",
|
|
50
|
-
"vsrepository"
|
|
49
|
+
"vsrepository",
|
|
50
|
+
"jparepository"
|
|
51
51
|
],
|
|
52
52
|
"author": "João Pedro Azevedo Freire Mecenas",
|
|
53
53
|
"license": "MIT",
|