@plurnk/plurnk-execs-sqlite 0.1.11 → 0.1.13

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.
Files changed (2) hide show
  1. package/README.md +10 -0
  2. package/package.json +4 -4
package/README.md CHANGED
@@ -21,6 +21,16 @@ The EXEC target slot is the database file; with no target it defaults to an ephe
21
21
 
22
22
  `:memory:` is ephemeral — state does not persist across EXECs. Pass a file path for persistence.
23
23
 
24
+ ### Transient tabular calculations
25
+
26
+ With no target, `:memory:` is a scratch calculator over ad-hoc tables — build one inline with `VALUES` and aggregate, no schema or file needed:
27
+
28
+ ```
29
+ <<EXEC[sqlite]:WITH t(item,qty,price) AS (VALUES ('a',3,2),('b',1,5)) SELECT sum(qty*price) AS total, sum(qty*price)*1.0/sum(qty) AS avg_price FROM t:EXEC
30
+ ```
31
+
32
+ **Use floats to avoid integer truncation.** SQLite integer division truncates — `11/4` → `2`. Multiply by `1.0` (or `CAST(x AS REAL)`) to force real division: `11*1.0/4` → `2.75`. Any division over integer columns needs this, or the result is silently floored.
33
+
24
34
  ## Output
25
35
 
26
36
  Writes to the `results` channel as `application/json`, ready for the jsonpath body-matcher (plurnk-mimetypes' JSON handler):
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plurnk/plurnk-execs-sqlite",
3
- "version": "0.1.11",
3
+ "version": "0.1.13",
4
4
  "description": "SQLite runtime executor for plurnk-service's exec scheme — runs the sqlite runtime tag in-process via node:sqlite, results as application/json.",
5
5
  "keywords": [
6
6
  "plurnk",
@@ -33,7 +33,7 @@
33
33
  {
34
34
  "name": "sqlite",
35
35
  "glyph": "🗃",
36
- "example": "<<EXEC[sqlite](./app.db):SELECT count(*) FROM users:EXEC"
36
+ "example": "<<EXEC[sqlite](./app.db):SELECT count(*) FROM users:EXEC\n<<EXEC[sqlite]:WITH t(item,qty,price) AS (VALUES ('a',3,2),('b',1,5)) SELECT sum(qty*price) AS total, sum(qty*price)*1.0/sum(qty) AS avg_price FROM t:EXEC"
37
37
  }
38
38
  ]
39
39
  },
@@ -60,9 +60,9 @@
60
60
  "devDependencies": {
61
61
  "@types/node": "^26.0.0",
62
62
  "typescript": "^6.0.3",
63
- "@plurnk/plurnk-execs": "^0.4.26"
63
+ "@plurnk/plurnk-execs": "0.4.28"
64
64
  },
65
65
  "peerDependencies": {
66
- "@plurnk/plurnk-execs": "^0.4.26"
66
+ "@plurnk/plurnk-execs": "0.4.28"
67
67
  }
68
68
  }