@prisma-idb/idb-client-generator 0.2.1 → 0.3.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/.release-it.json
CHANGED
|
@@ -6,9 +6,13 @@ function addCountMethod(modelClass, model) {
|
|
|
6
6
|
name: "count",
|
|
7
7
|
isAsync: true,
|
|
8
8
|
typeParameters: [{ name: "Q", constraint: `Prisma.Args<Prisma.${model.name}Delegate, 'count'>` }],
|
|
9
|
-
parameters: [
|
|
9
|
+
parameters: [
|
|
10
|
+
{ name: "query", hasQuestionToken: true, type: "Q" },
|
|
11
|
+
{ name: "tx", hasQuestionToken: true, type: "IDBUtils.TransactionType" },
|
|
12
|
+
],
|
|
10
13
|
returnType: `Promise<Prisma.Result<Prisma.${model.name}Delegate, Q, 'count'>>`,
|
|
11
14
|
statements: (writer) => {
|
|
15
|
+
writer.writeLine(`tx = tx ?? this.client._db.transaction(["${model.name}"], "readonly");`);
|
|
12
16
|
handleWithoutSelect(writer, model);
|
|
13
17
|
handleWithSelect(writer, model);
|
|
14
18
|
},
|
|
@@ -17,8 +21,8 @@ function addCountMethod(modelClass, model) {
|
|
|
17
21
|
function handleWithoutSelect(writer, model) {
|
|
18
22
|
writer.writeLine(`if (!query?.select || query.select === true)`).block(() => {
|
|
19
23
|
writer
|
|
20
|
-
.writeLine(`const
|
|
21
|
-
.writeLine(`return
|
|
24
|
+
.writeLine(`const totalRecords = await tx.objectStore("${model.name}").count();`)
|
|
25
|
+
.writeLine(`return totalRecords as Prisma.Result<Prisma.${model.name}Delegate, Q, "count">;`);
|
|
22
26
|
});
|
|
23
27
|
}
|
|
24
28
|
function handleWithSelect(writer, model) {
|
|
@@ -31,10 +35,10 @@ function handleWithSelect(writer, model) {
|
|
|
31
35
|
.writeLine(`if (typedKey === "_all")`)
|
|
32
36
|
.block(() => {
|
|
33
37
|
writer
|
|
34
|
-
.writeLine(`result[typedKey] = (await this.findMany({ where: query.where })).length;`)
|
|
38
|
+
.writeLine(`result[typedKey] = (await this.findMany({ where: query.where }, tx)).length;`)
|
|
35
39
|
.writeLine(`continue;`);
|
|
36
40
|
})
|
|
37
|
-
.writeLine("result[typedKey] = (await this.findMany({ where: { [`${typedKey}`]: { not: null } } })).length;");
|
|
41
|
+
.writeLine("result[typedKey] = (await this.findMany({ where: { [`${typedKey}`]: { not: null } } }, tx)).length;");
|
|
38
42
|
})
|
|
39
43
|
.writeLine(`return result as Prisma.Result<Prisma.UserDelegate, Q, "count">;`);
|
|
40
44
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"count.js","sourceRoot":"","sources":["../../../../../../src/fileCreators/prisma-idb-client/classes/models/api/count.ts"],"names":[],"mappings":";;AAGA,
|
|
1
|
+
{"version":3,"file":"count.js","sourceRoot":"","sources":["../../../../../../src/fileCreators/prisma-idb-client/classes/models/api/count.ts"],"names":[],"mappings":";;AAGA,wCAgBC;AAhBD,SAAgB,cAAc,CAAC,UAA4B,EAAE,KAAY;IACvE,UAAU,CAAC,SAAS,CAAC;QACnB,IAAI,EAAE,OAAO;QACb,OAAO,EAAE,IAAI;QACb,cAAc,EAAE,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,UAAU,EAAE,sBAAsB,KAAK,CAAC,IAAI,oBAAoB,EAAE,CAAC;QACjG,UAAU,EAAE;YACV,EAAE,IAAI,EAAE,OAAO,EAAE,gBAAgB,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE;YACpD,EAAE,IAAI,EAAE,IAAI,EAAE,gBAAgB,EAAE,IAAI,EAAE,IAAI,EAAE,0BAA0B,EAAE;SACzE;QACD,UAAU,EAAE,gCAAgC,KAAK,CAAC,IAAI,wBAAwB;QAC9E,UAAU,EAAE,CAAC,MAAM,EAAE,EAAE;YACrB,MAAM,CAAC,SAAS,CAAC,4CAA4C,KAAK,CAAC,IAAI,kBAAkB,CAAC,CAAC;YAC3F,mBAAmB,CAAC,MAAM,EAAE,KAAK,CAAC,CA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