Skip to content

Commit 53f9a90

Browse files
geeksilva97aduh95
authored andcommitted
doc,sqlite: document entryPoint argument for loadExtension
Signed-off-by: geeksilva97 <edigleyssonsilva@gmail.com> PR-URL: #63152 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: René <contact.9a5d6388@renegade334.me.uk>
1 parent c0175a9 commit 53f9a90

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
@@ -296,7 +296,7 @@ added: v22.5.0
296296
Closes the database connection. An exception is thrown if the database is not
297297
open. This method is a wrapper around [`sqlite3_close_v2()`][].
298298

299-
### `database.loadExtension(path)`
299+
### `database.loadExtension(path[, entryPoint])`
300300

301301
<!-- YAML
302302
added:
@@ -305,11 +305,37 @@ added:
305305
-->
306306

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

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

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

315341
<!-- YAML

0 commit comments

Comments
 (0)