@@ -287,7 +287,7 @@ added: v22.5.0 |
287 | 287 | Closes the database connection. An exception is thrown if the database is not |
288 | 288 | open. This method is a wrapper around [`sqlite3_close_v2()`][]. |
289 | 289 |
|
290 | | -### `database.loadExtension(path)` |
| 290 | +### `database.loadExtension(path[, entryPoint])` |
291 | 291 |
|
292 | 292 | <!-- YAML |
293 | 293 | added: |
@@ -296,11 +296,37 @@ added: |
296 | 296 | --> |
297 | 297 |
|
298 | 298 | * `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. |
299 | 302 |
|
300 | 303 | Loads a shared library into the database connection. This method is a wrapper |
301 | 304 | around [`sqlite3_load_extension()`][]. It is required to enable the |
302 | 305 | `allowExtension` option when constructing the `DatabaseSync` instance. |
303 | 306 |
|
| 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 | + |
304 | 330 | ### `database.enableLoadExtension(allow)` |
305 | 331 |
|
306 | 332 | <!-- YAML |
|