@form-engine-ts/storage-d1 7.18.1 → 8.0.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/dist/index.cjs +19 -0
- package/dist/index.js +19 -0
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -263,6 +263,25 @@ function createD1Storage(options) {
|
|
|
263
263
|
);
|
|
264
264
|
return rows.map(parseSubmissionRow);
|
|
265
265
|
},
|
|
266
|
+
async countSubmissions(formId, formVersion, queryOptions) {
|
|
267
|
+
await ensureReady();
|
|
268
|
+
const conditions = ["form_id = ?"];
|
|
269
|
+
const params = [formId];
|
|
270
|
+
if (formVersion !== void 0) {
|
|
271
|
+
conditions.push("form_version = ?");
|
|
272
|
+
params.push(formVersion);
|
|
273
|
+
}
|
|
274
|
+
if (queryOptions?.since !== void 0) {
|
|
275
|
+
conditions.push("submitted_at >= ?");
|
|
276
|
+
params.push(queryOptions.since);
|
|
277
|
+
}
|
|
278
|
+
if (queryOptions?.until !== void 0) {
|
|
279
|
+
conditions.push("submitted_at <= ?");
|
|
280
|
+
params.push(queryOptions.until);
|
|
281
|
+
}
|
|
282
|
+
const row = await options.db.prepare(`SELECT COUNT(*) AS count FROM ${responsesTable} WHERE ${conditions.join(" AND ")}`).bind(...params).first();
|
|
283
|
+
return Number(row?.count ?? 0);
|
|
284
|
+
},
|
|
266
285
|
async deleteSubmission(submissionId) {
|
|
267
286
|
await ensureReady();
|
|
268
287
|
await run(`DELETE FROM ${responsesTable} WHERE response_id = ?`, [submissionId]);
|
package/dist/index.js
CHANGED
|
@@ -242,6 +242,25 @@ function createD1Storage(options) {
|
|
|
242
242
|
);
|
|
243
243
|
return rows.map(parseSubmissionRow);
|
|
244
244
|
},
|
|
245
|
+
async countSubmissions(formId, formVersion, queryOptions) {
|
|
246
|
+
await ensureReady();
|
|
247
|
+
const conditions = ["form_id = ?"];
|
|
248
|
+
const params = [formId];
|
|
249
|
+
if (formVersion !== void 0) {
|
|
250
|
+
conditions.push("form_version = ?");
|
|
251
|
+
params.push(formVersion);
|
|
252
|
+
}
|
|
253
|
+
if (queryOptions?.since !== void 0) {
|
|
254
|
+
conditions.push("submitted_at >= ?");
|
|
255
|
+
params.push(queryOptions.since);
|
|
256
|
+
}
|
|
257
|
+
if (queryOptions?.until !== void 0) {
|
|
258
|
+
conditions.push("submitted_at <= ?");
|
|
259
|
+
params.push(queryOptions.until);
|
|
260
|
+
}
|
|
261
|
+
const row = await options.db.prepare(`SELECT COUNT(*) AS count FROM ${responsesTable} WHERE ${conditions.join(" AND ")}`).bind(...params).first();
|
|
262
|
+
return Number(row?.count ?? 0);
|
|
263
|
+
},
|
|
245
264
|
async deleteSubmission(submissionId) {
|
|
246
265
|
await ensureReady();
|
|
247
266
|
await run(`DELETE FROM ${responsesTable} WHERE response_id = ?`, [submissionId]);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@form-engine-ts/storage-d1",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "8.0.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"typescript"
|
|
42
42
|
],
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@form-engine-ts/core": "
|
|
44
|
+
"@form-engine-ts/core": "8.0.0"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"@cloudflare/workers-types": "^4.20240000.0"
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@cloudflare/workers-types": "^4.20240000.0",
|
|
56
|
-
"@form-engine-ts/storage": "
|
|
56
|
+
"@form-engine-ts/storage": "8.0.0"
|
|
57
57
|
},
|
|
58
58
|
"scripts": {
|
|
59
59
|
"build": "tsup src/index.ts --format esm,cjs --dts --clean --external @form-engine-ts/core",
|