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.
- package/.devcontainer/Dockerfile +1 -1
- package/.eslintrc.js +1 -0
- package/CONTRIBUTING.md +1 -2
- package/README.md +27 -0
- package/dist/sql-asm-debug.js +47177 -45836
- package/dist/sql-asm-memory-growth.js +112 -110
- package/dist/sql-asm.js +115 -112
- package/dist/sql-wasm-debug.js +1416 -1209
- package/dist/sql-wasm-debug.wasm +0 -0
- package/dist/sql-wasm.js +96 -95
- package/dist/sql-wasm.wasm +0 -0
- package/dist/sqljs-all.zip +0 -0
- package/dist/sqljs-wasm.zip +0 -0
- package/dist/sqljs-worker-wasm.zip +0 -0
- package/dist/worker.sql-asm-debug.js +47178 -45837
- package/dist/worker.sql-asm.js +115 -112
- package/dist/worker.sql-wasm-debug.js +1416 -1209
- package/dist/worker.sql-wasm.js +96 -95
- package/package.json +2 -2
package/.devcontainer/Dockerfile
CHANGED
|
@@ -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.
|
|
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
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
|
|
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
|
```
|