From e9b286ca4bb70cbc123e1adf2f674f7a2930b3b4 Mon Sep 17 00:00:00 2001 From: Edy Silva Date: Mon, 21 Apr 2025 11:57:15 -0300 Subject: [PATCH] sqlite: add location method PR-URL: https://github.com/nodejs/node/pull/57860 Reviewed-By: James M Snell Reviewed-By: Colin Ihrig --- doc/api/sqlite.md | 14 ++++++ src/node_sqlite.cc | 32 +++++++++++++ src/node_sqlite.h | 1 + test/parallel/test-sqlite-database-sync.js | 52 ++++++++++++++++++++++ 4 files changed, 99 insertions(+) diff --git a/doc/api/sqlite.md b/doc/api/sqlite.md index 0f077ed7981..beddcf90d25 100644 --- a/doc/api/sqlite.md +++ b/doc/api/sqlite.md @@ -241,6 +241,19 @@ Enables or disables the `loadExtension` SQL function, and the `loadExtension()` method. When `allowExtension` is `false` when constructing, you cannot enable loading extensions for security reasons. +### `database.location([dbName])` + + + +* `dbName` {string} Name of the database. This can be `'main'` (the default primary database) or any other + database that has been added with [`ATTACH DATABASE`][] **Default:** `'main'`. +* Returns: {string | null} The location of the database file. When using an in-memory database, + this method returns null. + +This method is a wrapper around [`sqlite3_db_filename()`][] + ### `database.exec(sql)`