From 7485309d7eb760bddd3bbd27e70e3d4d3a907435 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 82b8366b6c1..ef5ed150aab 100644 --- a/doc/api/sqlite.md +++ b/doc/api/sqlite.md @@ -237,6 +237,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)`