Skip to content

Commit e369886

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 64efbfd commit e369886

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

290-
### `database.loadExtension(path)`
290+
### `database.loadExtension(path[, entryPoint])`
291291

292292
<!-- YAML
293293
added:
@@ -296,11 +296,37 @@ added:
296296
-->
297297

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

300303
Loads a shared library into the database connection. This method is a wrapper
301304
around [`sqlite3_load_extension()`][]. It is required to enable the
302305
`allowExtension` option when constructing the `DatabaseSync` instance.
303306

307+
```mjs
308+
import { DatabaseSync } from 'node:sqlite';
309+
const database = new DatabaseSync(':memory:', { allowExtension: true });
310+
311+
// Load using the entry point derived from the filename.
312+
database.loadExtension('./decimal.dylib');
313+
314+
// Override the entry point when the derived name does not match.
315+
database.loadExtension('./base64.dylib', 'sqlite3_base64_init');
316+
```
317+
318+
```cjs
319+
'use strict';
320+
const { DatabaseSync } = require('node:sqlite');
321+
const database = new DatabaseSync(':memory:', { allowExtension: true });
322+
323+
// Load using the entry point derived from the filename.
324+
database.loadExtension('./decimal.dylib');
325+
326+
// Override the entry point when the derived name does not match.
327+
database.loadExtension('./base64.dylib', 'sqlite3_base64_init');
328+
```
329+
304330
### `database.enableLoadExtension(allow)`
305331

306332
<!-- YAML

0 commit comments

Comments
 (0)