Skip to content

Commit 4e10879

Browse files
committed
doc,sqlite: document entryPoint argument for loadExtension
Signed-off-by: geeksilva97 <edigleyssonsilva@gmail.com>
1 parent e690df3 commit 4e10879

1 file changed

Lines changed: 27 additions & 1 deletion

File tree

doc/api/sqlite.md

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ added: v22.5.0
298298
Closes the database connection. An exception is thrown if the database is not
299299
open. This method is a wrapper around [`sqlite3_close_v2()`][].
300300

301-
### `database.loadExtension(path)`
301+
### `database.loadExtension(path[, entryPoint])`
302302

303303
<!-- YAML
304304
added:
@@ -307,11 +307,37 @@ added:
307307
-->
308308

309309
* `path` {string} The path to the shared library to load.
310+
* `entryPoint` {string} The name of the extension's entry-point function. When
311+
omitted, SQLite derives the entry point from the shared library's filename;
312+
pass this argument explicitly when the derived name does not match.
310313

311314
Loads a shared library into the database connection. This method is a wrapper
312315
around [`sqlite3_load_extension()`][]. It is required to enable the
313316
`allowExtension` option when constructing the `DatabaseSync` instance.
314317

318+
```mjs
319+
import { DatabaseSync } from 'node:sqlite';
320+
const database = new DatabaseSync(':memory:', { allowExtension: true });
321+
322+
// Load using the entry point derived from the filename.
323+
database.loadExtension('./decimal.dylib');
324+
325+
// Override the entry point when the derived name does not match.
326+
database.loadExtension('./base64.dylib', 'sqlite3_base64_init');
327+
```
328+
329+
```cjs
330+
'use strict';
331+
const { DatabaseSync } = require('node:sqlite');
332+
const database = new DatabaseSync(':memory:', { allowExtension: true });
333+
334+
// Load using the entry point derived from the filename.
335+
database.loadExtension('./decimal.dylib');
336+
337+
// Override the entry point when the derived name does not match.
338+
database.loadExtension('./base64.dylib', 'sqlite3_base64_init');
339+
```
340+
315341
### `database.enableLoadExtension(allow)`
316342

317343
<!-- YAML

0 commit comments

Comments
 (0)