sql.js 1.7.0 → 1.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.
@@ -24,7 +24,7 @@ FROM mcr.microsoft.com/vscode/devcontainers/typescript-node:0-${VARIANT}
24
24
  # Install EMSDK to /emsdk just like the EMSDK Dockerfile: https://github.com/emscripten-core/emsdk/blob/master/docker/Dockerfile
25
25
  ENV EMSDK /emsdk
26
26
  # We pin the EMSDK version rather than 'latest' so that everyone is using the same compiler version
27
- ENV EMSCRIPTEN_VERSION 3.1.8
27
+ ENV EMSCRIPTEN_VERSION 3.1.20
28
28
 
29
29
  RUN git clone https://github.com/emscripten-core/emsdk.git $EMSDK
30
30
 
package/.eslintrc.js CHANGED
@@ -16,6 +16,7 @@ module.exports = {
16
16
  ignorePatterns: [
17
17
  "/dist/",
18
18
  "/examples/",
19
+ "/documentation/",
19
20
  "/node_modules/",
20
21
  "/out/",
21
22
  "/src/shell-post.js",
package/CONTRIBUTING.md CHANGED
@@ -52,7 +52,7 @@ Instructions:
52
52
 
53
53
  ## Compiling SQLite with different options
54
54
 
55
- In order to enable extensions like JSON1 or FTS5, change the CFLAGS in the [Makefile](Makefile) and run `npm run rebuild`:
55
+ In order to enable extensions like FTS5, change the CFLAGS in the [Makefile](Makefile) and run `npm run rebuild`:
56
56
 
57
57
  ``` diff
58
58
  CFLAGS = \
@@ -62,6 +62,5 @@ CFLAGS = \
62
62
  -DSQLITE_ENABLE_FTS3 \
63
63
  -DSQLITE_ENABLE_FTS3_PARENTHESIS \
64
64
  + -DSQLITE_ENABLE_FTS5 \
65
- + -DSQLITE_ENABLE_JSON1 \
66
65
  -DSQLITE_THREADSAFE=0
67
66
  ```
package/README.md CHANGED
@@ -75,6 +75,33 @@ db.create_function("add_js", add);
75
75
  // Run a query in which the function is used
76
76
  db.run("INSERT INTO hello VALUES (add_js(7, 3), add_js('Hello ', 'world'));"); // Inserts 10 and 'Hello world'
77
77
 
78
+ // You can create custom aggregation functions, by passing a name
79
+ // and a set of functions to `db.create_aggregate`:
80
+ //
81
+ // - an `init` function. This function receives no argument and returns
82
+ // the initial value for the state of the aggregate function.
83
+ // - a `step` function. This function takes two arguments
84
+ // - the current state of the aggregation
85
+ // - a new value to aggregate to the state
86
+ // It should return a new value for the state.
87
+ // - a `finalize` function. This function receives a state object, and
88
+ // returns the final value of the aggregate. It can be omitted, in which case
89
+ // the final value of the state will be returned directly by the aggregate function.
90
+ //
91
+ // Here is an example aggregation function, `json_agg`, which will collect all
92
+ // input values and return them as a JSON array:
93
+ db.create_aggregate(
94
+ "json_agg",
95
+ {
96
+ init: () => [],
97
+ step: (state, val) => [...state, val],
98
+ finalize: (state) => JSON.stringify(state),
99
+ }
100
+ );
101
+
102
+ db.exec("SELECT json_agg(column1) FROM (VALUES ('hello'), ('world'))");
103
+ // -> The result of the query is the string '["hello","world"]'
104
+
78
105
  // Export the database to an Uint8Array containing the SQLite database file
79
106
  const binaryArray = db.export();
80
107
  ```