You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+17-1Lines changed: 17 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,16 +10,18 @@ SQLite-JS is a powerful extension that brings JavaScript capabilities to SQLite.
10
10
-[Aggregate Functions](#aggregate-functions)
11
11
-[Window Functions](#window-functions)
12
12
-[Collation Sequences](#collation-sequences)
13
+
-[Sync JavaScript Functions Across Devices](#syncing-across-devices)
13
14
-[JavaScript Evaluation](#javascript-evaluation)
14
15
-[Examples](#examples)
16
+
-[Update Functions](#update-functions)
15
17
-[Building from Source](#building-from-source)
16
18
-[License](#license)
17
19
18
20
## Installation
19
21
20
22
### Pre-built Binaries
21
23
22
-
Download the appropriate pre-built binary for your platform from the official [Release](https://github.com/sqliteai/sqlite-js/releases) page:
24
+
Download the appropriate pre-built binary for your platform from the official [Releases](https://github.com/sqliteai/sqlite-js/releases) page:
23
25
24
26
- Linux: x86 and ARM
25
27
- macOS: x86 and ARM
@@ -221,6 +223,16 @@ SELECT js_create_collation('natural_nocase', 'function(a, b) {
221
223
SELECT*FROM files ORDER BY name COLLATE natural_nocase;
222
224
```
223
225
226
+
## Syncing Across Devices
227
+
228
+
When used with [sqlite-sync](https://github.com/sqliteai/sqlite-sync/), user-defined functions created via sqlite-js are automatically replicated across the SQLite Cloud cluster, ensuring that all connected peers share the same logic and behavior — even offline. To enable automatic persistence and sync the special `js_init_table` function must be executed.
229
+
230
+
### Usage
231
+
```sql
232
+
SELECT js_init_table(); -- Create table if needed (no loading)
233
+
SELECT js_init_table(true); -- Create table and load all stored functions at startup
234
+
```
235
+
224
236
## JavaScript Evaluation
225
237
226
238
The extension also provides a way to directly evaluate JavaScript code within SQLite queries.
@@ -320,6 +332,10 @@ SELECT name, score,
320
332
FROM exam_results;
321
333
```
322
334
335
+
## Update Functions
336
+
337
+
Due to a constraint in [SQLite](https://www3.sqlite.org/src/info/cabab62bc10568d4), it is not possible to update or redefine a user-defined function using the same database connection that was used to initially register it. To modify an existing JavaScript function, the update must be performed through a separate database connection.
338
+
323
339
## Building from Source
324
340
325
341
See the included Makefile for building instructions:
0 commit comments