Skip to content

Commit bc82ad2

Browse files
authored
Update README.md
1 parent 6de6fcc commit bc82ad2

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

README.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,18 @@ SQLite-JS is a powerful extension that brings JavaScript capabilities to SQLite.
1010
- [Aggregate Functions](#aggregate-functions)
1111
- [Window Functions](#window-functions)
1212
- [Collation Sequences](#collation-sequences)
13+
- [Sync JavaScript Functions Across Devices](#syncing-across-devices)
1314
- [JavaScript Evaluation](#javascript-evaluation)
1415
- [Examples](#examples)
16+
- [Update Functions](#update-functions)
1517
- [Building from Source](#building-from-source)
1618
- [License](#license)
1719

1820
## Installation
1921

2022
### Pre-built Binaries
2123

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:
2325

2426
- Linux: x86 and ARM
2527
- macOS: x86 and ARM
@@ -221,6 +223,16 @@ SELECT js_create_collation('natural_nocase', 'function(a, b) {
221223
SELECT * FROM files ORDER BY name COLLATE natural_nocase;
222224
```
223225

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+
224236
## JavaScript Evaluation
225237

226238
The extension also provides a way to directly evaluate JavaScript code within SQLite queries.
@@ -320,6 +332,10 @@ SELECT name, score,
320332
FROM exam_results;
321333
```
322334

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+
323339
## Building from Source
324340

325341
See the included Makefile for building instructions:

0 commit comments

Comments
 (0)