Skip to content

Commit 531183d

Browse files
geeksilva97juanarbol
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 e193a84 commit 531183d

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
@@ -229,18 +229,44 @@ added: v22.5.0
229229
Closes the database connection. An exception is thrown if the database is not
230230
open. This method is a wrapper around [`sqlite3_close_v2()`][].
231231

232-
### `database.loadExtension(path)`
232+
### `database.loadExtension(path[, entryPoint])`
233233

234234
<!-- YAML
235235
added: v22.13.0
236236
-->
237237

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

240243
Loads a shared library into the database connection. This method is a wrapper
241244
around [`sqlite3_load_extension()`][]. It is required to enable the
242245
`allowExtension` option when constructing the `DatabaseSync` instance.
243246

247+
```mjs
248+
import { DatabaseSync } from 'node:sqlite';
249+
const database = new DatabaseSync(':memory:', { allowExtension: true });
250+
251+
// Load using the entry point derived from the filename.
252+
database.loadExtension('./decimal.dylib');
253+
254+
// Override the entry point when the derived name does not match.
255+
database.loadExtension('./base64.dylib', 'sqlite3_base64_init');
256+
```
257+
258+
```cjs
259+
'use strict';
260+
const { DatabaseSync } = require('node:sqlite');
261+
const database = new DatabaseSync(':memory:', { allowExtension: true });
262+
263+
// Load using the entry point derived from the filename.
264+
database.loadExtension('./decimal.dylib');
265+
266+
// Override the entry point when the derived name does not match.
267+
database.loadExtension('./base64.dylib', 'sqlite3_base64_init');
268+
```
269+
244270
### `database.enableLoadExtension(allow)`
245271

246272
<!-- YAML

0 commit comments

Comments
 (0)