From 0909d3e138cbe0a49b24e40257527f815f03f8f1 Mon Sep 17 00:00:00 2001 From: Edy Silva Date: Fri, 24 Jan 2025 12:09:33 -0300 Subject: [PATCH] sqlite,test,doc: move backup implementation to a separate function --- doc/api/sqlite.md | 41 ++--- src/env_properties.h | 1 + src/node_sqlite.cc | 226 ++++++++++++++------------- src/node_sqlite.h | 1 - test/parallel/test-sqlite-backup.mjs | 51 +++--- 5 files changed, 171 insertions(+), 149 deletions(-) diff --git a/doc/api/sqlite.md b/doc/api/sqlite.md index 08fea8d233aed2..742b7665e44ce4 100644 --- a/doc/api/sqlite.md +++ b/doc/api/sqlite.md @@ -115,26 +115,6 @@ added: v22.5.0 Constructs a new `DatabaseSync` instance. -### `database.backup(destination[, options])` - - - -* `destination` {string} The path where the backup will be created. If the file already exists, the contents will be - overwritten. -* `options` {Object} Optional configuration for the backup. The - following properties are supported: - * `source` {string} Name of the source database. **Default:** `'main'`. - * `target` {string} Name of the target database. **Default:** `'main'`. - * `rate` {number} Number of pages to be transmitted in each batch of the backup. **Default:** `100`. - * `progress` {Function} Callback function that will be called with the number of pages copied and the total number of - pages. -* Returns: {Promise} A promise that resolves when the backup is completed and rejects if an error occurs. - -This method makes a database backup. This method abstracts the [`sqlite3_backup_init()`][], [`sqlite3_backup_step()`][] -and [`sqlite3_backup_finish()`][] functions. - ### `database.close()` + +* `sourceDb` A `DatabaseSync` object to be the source of the backup. The source database must be open. +* `destination` {string} The path where the backup will be created. If the file already exists, the contents will be + overwritten. +* `options` {Object} Optional configuration for the backup. The + following properties are supported: + * `source` {string} Name of the source database. **Default:** `'main'`. + * `target` {string} Name of the target database. **Default:** `'main'`. + * `rate` {number} Number of pages to be transmitted in each batch of the backup. **Default:** `100`. + * `progress` {Function} Callback function that will be called with the number of pages copied and the total number of + pages. +* Returns: {Promise} A promise that resolves when the backup is completed and rejects if an error occurs. + +This method makes a database backup. This method abstracts the [`sqlite3_backup_init()`][], [`sqlite3_backup_step()`][] +and [`sqlite3_backup_finish()`][] functions. + ## `sqlite.constants`