Skip to content

Commit 084819a

Browse files
committed
updated verbiage of various documentation
1 parent 2e86258 commit 084819a

12 files changed

+42
-42
lines changed

README.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# better-sqlite3 [![Build Status](https://github.com/JoshuaWise/better-sqlite3/actions/workflows/build.yml/badge.svg)](https://github.com/JoshuaWise/better-sqlite3/actions/workflows/build.yml?query=branch%3Amaster)
22

3-
The fastest and simplest library for SQLite3 in Node.js.
3+
The fastest and simplest library for SQLite in Node.js.
44

55
- Full transaction support
66
- High performance, efficiency, and safety
@@ -32,7 +32,7 @@ The fastest and simplest library for SQLite3 in Node.js.
3232
npm install better-sqlite3
3333
```
3434

35-
> Prebuilt binaries are available for [LTS versions](https://nodejs.org/en/about/releases/). If you have trouble installing, check the [troubleshooting guide](./docs/troubleshooting.md).
35+
> Requires Node.js v14.21.1 or later. Prebuilt binaries are available for [LTS versions](https://nodejs.org/en/about/releases/). If you have trouble installing, check the [troubleshooting guide](./docs/troubleshooting.md).
3636
3737
## Usage
3838

@@ -66,7 +66,7 @@ db.pragma('journal_mode = WAL');
6666

6767
#### When is this library not appropriate?
6868

69-
In most cases, if you're attempting something that cannot be reasonably accomplished with `better-sqlite3`, it probably cannot be reasonably accomplished with SQLite3 in general. For example, if you're executing queries that take one second to complete, and you expect to have many concurrent users executing those queries, no amount of asynchronicity will save you from SQLite3's serialized nature. Fortunately, SQLite3 is very *very* fast. With proper indexing, we've been able to achieve upward of 2000 queries per second with 5-way-joins in a 60 GB database, where each query was handling 5–50 kilobytes of real data.
69+
In most cases, if you're attempting something that cannot be reasonably accomplished with `better-sqlite3`, it probably cannot be reasonably accomplished with SQLite in general. For example, if you're executing queries that take one second to complete, and you expect to have many concurrent users executing those queries, no amount of asynchronicity will save you from SQLite's serialized nature. Fortunately, SQLite is very *very* fast. With proper indexing, we've been able to achieve upward of 2000 queries per second with 5-way-joins in a 60 GB database, where each query was handling 5–50 kilobytes of real data.
7070

7171
If you have a performance problem, the most likely causes are inefficient queries, improper indexing, or a lack of [WAL mode](./docs/performance.md)—not `better-sqlite3` itself. However, there are some cases where `better-sqlite3` could be inappropriate:
7272

@@ -78,10 +78,10 @@ For these situations, you should probably use a full-fledged RDBMS such as [Post
7878

7979
## Upgrading
8080

81-
Upgrading your `better-sqlite3` dependency can potentially introduce breaking changes, either in the `better-sqlite3` API, or between your existing database(s) and the underlying version of SQLite. Before upgrading, review:
81+
Upgrading your `better-sqlite3` dependency can potentially introduce breaking changes, either in the `better-sqlite3` API (if you upgrade to a new [major version](https://semver.org/)), or between your existing database(s) and the underlying version of SQLite. Before upgrading, review:
8282

83-
* `better-sqlite3` release notes: https://github.com/WiseLibs/better-sqlite3/releases
84-
* SQLite changelog: https://www.sqlite.org/changes.html
83+
* [`better-sqlite3` release notes](https://github.com/WiseLibs/better-sqlite3/releases)
84+
* [SQLite release history](https://www.sqlite.org/changes.html)
8585

8686
# Documentation
8787

@@ -90,7 +90,7 @@ Upgrading your `better-sqlite3` dependency can potentially introduce breaking ch
9090
- [64-bit integer support](./docs/integer.md)
9191
- [Worker thread support](./docs/threads.md)
9292
- [Unsafe mode (advanced)](./docs/unsafe.md)
93-
- [SQLite3 compilation (advanced)](./docs/compilation.md)
93+
- [SQLite compilation (advanced)](./docs/compilation.md)
9494
- [Contribution rules](./docs/contribution.md)
9595
- [Code of conduct](./docs/conduct.md)
9696

benchmark/drivers.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

33
/*
4-
Every benchmark trial will be executed once for each SQLite3 driver listed
4+
Every benchmark trial will be executed once for each SQLite driver listed
55
below. Each driver has a function to open a new database connection on a
66
given filename and a list of PRAGMA statements.
77
*/

binding.gyp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# ===
2-
# This is the main GYP file, which builds better-sqlite3 with SQLite3 itself.
2+
# This is the main GYP file, which builds better-sqlite3 with SQLite itself.
33
# ===
44

55
{

deps/download.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
#!/usr/bin/env bash
22

33
# ===
4-
# This script defines and generates the bundled SQLite3 unit (sqlite3.c).
4+
# This script defines and generates the bundled SQLite unit (sqlite3.c).
55
#
66
# The following steps are taken:
77
# 1. populate the shell environment with the defined compile-time options.
8-
# 2. download and extract the SQLite3 source code into a temporary directory.
8+
# 2. download and extract the SQLite source code into a temporary directory.
99
# 3. run "sh configure" and "make sqlite3.c" within the source directory.
1010
# 4. copy the generated amalgamation into the output directory (./sqlite3).
1111
# 5. export the defined compile-time options to a gyp file (./defines.gypi).

deps/sqlite3.gyp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# ===
2-
# This configuration defines options specific to compiling SQLite3 itself.
2+
# This configuration defines options specific to compiling SQLite itself.
33
# Compile-time options are loaded by the auto-generated file "defines.gypi".
44
# The --sqlite3 option can be provided to use a custom amalgamation instead.
55
# ===

deps/test_extension.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
SQLITE_EXTENSION_INIT1
33

44
/*
5-
This SQLite3 extension is used only for testing purposes (npm test).
5+
This SQLite extension is used only for testing purposes (npm test).
66
*/
77

88
static void TestExtensionFunction(sqlite3_context* pCtx, int nVal, sqlite3_value** _) {

docs/api.md

+17-17
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,9 @@ Any arguments passed to the transaction function will be forwarded to the wrappe
9898

9999
If you'd like to manage transactions manually, you're free to do so with regular [prepared statements](#preparestring---statement) (using `BEGIN`, `COMMIT`, etc.). However, manually managed transactions should not be mixed with transactions managed by this `.transaction()` method. In other words, using raw `COMMIT` or `ROLLBACK` statements inside a transaction function is not supported.
100100

101-
Transaction functions do not work with async functions. Technically speaking, async functions always return after the first `await`, which means the transaction will already be committed before any async code executes. Also, because SQLite3 serializes all transactions, it's generally a very bad idea to keep a transaction open across event loop ticks anyways.
101+
Transaction functions do not work with async functions. Technically speaking, async functions always return after the first `await`, which means the transaction will already be committed before any async code executes. Also, because SQLite serializes all transactions, it's generally a very bad idea to keep a transaction open across event loop ticks anyways.
102102

103-
It's important to know that SQLite3 may sometimes rollback a transaction without us asking it to. This can happen either because of an [`ON CONFLICT`](https://sqlite.org/lang_conflict.html) clause, the [`RAISE()`](https://www.sqlite.org/lang_createtrigger.html) trigger function, or certain errors such as `SQLITE_FULL` or `SQLITE_BUSY`. In other words, if you catch an SQLite3 error *within* a transaction, you must be aware that any further SQL that you execute might not be within the same transaction. Usually, the best course of action for such cases is to simply re-throw the error, exiting the transaction function.
103+
It's important to know that SQLite may sometimes rollback a transaction without us asking it to. This can happen either because of an [`ON CONFLICT`](https://sqlite.org/lang_conflict.html) clause, the [`RAISE()`](https://www.sqlite.org/lang_createtrigger.html) trigger function, or certain errors such as `SQLITE_FULL` or `SQLITE_BUSY`. In other words, if you catch an SQLite error *within* a transaction, you must be aware that any further SQL that you execute might not be within the same transaction. Usually, the best course of action for such cases is to simply re-throw the error, exiting the transaction function.
104104

105105
```js
106106
try {
@@ -124,11 +124,11 @@ console.log(db.pragma('cache_size', { simple: true })); // => 32000
124124

125125
If execution of the PRAGMA fails, an `Error` is thrown.
126126

127-
It's better to use this method instead of normal [prepared statements](#preparestring---statement) when executing PRAGMA, because this method normalizes some odd behavior that may otherwise be experienced. The documentation on SQLite3 PRAGMA can be found [here](https://www.sqlite.org/pragma.html).
127+
It's better to use this method instead of normal [prepared statements](#preparestring---statement) when executing PRAGMA, because this method normalizes some odd behavior that may otherwise be experienced. The documentation on SQLite PRAGMA can be found [here](https://www.sqlite.org/pragma.html).
128128

129129
### .backup(*destination*, [*options*]) -> *promise*
130130

131-
Initiates a [backup](https://www.sqlite.org/backup.html) of the database, returning a [promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Using_promises) for when the backup is complete. If the backup fails, the promise will be rejected with an `Error`. You can optionally backup an attached database instead by setting the `attached` option to the name of the desired attached database. A backup file is just a regular SQLite3 database file. It can be opened by [`new Database()`](#new-databasepath-options) just like any SQLite3 database.
131+
Initiates a [backup](https://www.sqlite.org/backup.html) of the database, returning a [promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Using_promises) for when the backup is complete. If the backup fails, the promise will be rejected with an `Error`. You can optionally backup an attached database instead by setting the `attached` option to the name of the desired attached database. A backup file is just a regular SQLite database file. It can be opened by [`new Database()`](#new-databasepath-options) just like any SQLite database.
132132

133133
```js
134134
db.backup(`backup-${Date.now()}.db`)
@@ -165,7 +165,7 @@ db.backup(`backup-${Date.now()}.db`, {
165165

166166
Returns a [buffer](https://nodejs.org/api/buffer.html#buffer_class_buffer) containing the serialized contents of the database. You can optionally serialize an attached database instead by setting the `attached` option to the name of the desired attached database.
167167

168-
The returned buffer can be written to disk to create a regular SQLite3 database file, or it can be opened directly as an in-memory database by passing it to [`new Database()`](#new-databasepath-options).
168+
The returned buffer can be written to disk to create a regular SQLite database file, or it can be opened directly as an in-memory database by passing it to [`new Database()`](#new-databasepath-options).
169169

170170
```js
171171
const buffer = db.serialize();
@@ -185,7 +185,7 @@ db.prepare('SELECT add2(?, ?)').pluck().get('foo', 'bar'); // => "foobar"
185185
db.prepare('SELECT add2(?, ?, ?)').pluck().get(12, 4, 18); // => Error: wrong number of arguments
186186
```
187187

188-
By default, user-defined functions have a strict number of arguments (determined by `function.length`). You can register multiple functions of the same name, each with a different number of arguments, causing SQLite3 to execute a different function depending on how many arguments were passed to it. If you register two functions with same name and the same number of arguments, the second registration will erase the first one.
188+
By default, user-defined functions have a strict number of arguments (determined by `function.length`). You can register multiple functions of the same name, each with a different number of arguments, causing SQLite to execute a different function depending on how many arguments were passed to it. If you register two functions with same name and the same number of arguments, the second registration will erase the first one.
189189

190190
If `options.varargs` is `true`, the registered function can accept any number of arguments.
191191

@@ -231,7 +231,7 @@ db.aggregate('getAverage', {
231231
db.prepare('SELECT getAverage(dollars) FROM expenses').pluck().get(); // => 20.2
232232
```
233233

234-
As shown above, you can use arbitrary JavaScript objects as your aggregation context, as long as a valid SQLite3 value is returned by `result()` in the end. If `step()` doesn't return anything (`undefined`), the aggregate value will not be replaced (be careful of this when using functions that return `undefined` when `null` is desired).
234+
As shown above, you can use arbitrary JavaScript objects as your aggregation context, as long as a valid SQLite value is returned by `result()` in the end. If `step()` doesn't return anything (`undefined`), the aggregate value will not be replaced (be careful of this when using functions that return `undefined` when `null` is desired).
235235

236236
Just like regular [user-defined functions](#functionname-options-function---this), user-defined aggregates can accept multiple arguments. Furthermore, `options.varargs`, `options.directOnly`, and `options.deterministic` [are also](#functionname-options-function---this) accepted.
237237

@@ -358,17 +358,17 @@ db.exec('CREATE VIRTUAL TABLE my_data USING csv(my_data.csv)');
358358
const allData = db.prepare('SELECT * FROM my_data').all();
359359
```
360360

361-
The factory function will be invoked each time a corresponding `CREATE VIRTUAL TABLE` statement runs. The arguments to the factory function correspond to the module arguments passed in the `CREATE VIRTUAL TABLE` statement; always a list of arbitrary strings separated by commas. It's your responsibility to parse and interpret those module arguments. Note that SQLite3 does not allow [bound parameters](#binding-parameters) inside module arguments.
361+
The factory function will be invoked each time a corresponding `CREATE VIRTUAL TABLE` statement runs. The arguments to the factory function correspond to the module arguments passed in the `CREATE VIRTUAL TABLE` statement; always a list of arbitrary strings separated by commas. It's your responsibility to parse and interpret those module arguments. Note that SQLite does not allow [bound parameters](#binding-parameters) inside module arguments.
362362

363363
Just like [user-defined functions](#functionname-options-function---this) and [user-defined aggregates](#aggregatename-options---this), virtual tables support `options.directOnly`, which prevents the table from being used inside [VIEWs](https://sqlite.org/lang_createview.html), [TRIGGERs](https://sqlite.org/lang_createtrigger.html), or schema structures such as [CHECK constraints](https://www.sqlite.org/lang_createtable.html#ckconst), [DEFAULT clauses](https://www.sqlite.org/lang_createtable.html#dfltval), etc.
364364

365365
> Some [extensions](#loadextensionpath-entrypoint---this) can provide virtual tables that have write capabilities, but `db.table()` is only capable of creating read-only virtual tables, primarily for the purpose of supporting table-valued functions.
366366
367367
### .loadExtension(*path*, [*entryPoint*]) -> *this*
368368

369-
Loads a compiled [SQLite3 extension](https://sqlite.org/loadext.html) and applies it to the current database connection.
369+
Loads a compiled [SQLite extension](https://sqlite.org/loadext.html) and applies it to the current database connection.
370370

371-
It's your responsibility to make sure the extensions you load are compiled/linked against a version of [SQLite3](https://www.sqlite.org/) that is compatible with `better-sqlite3`. Keep in mind that new versions of `better-sqlite3` will periodically use newer versions of [SQLite3](https://www.sqlite.org/). You can see which version is being used [here](./compilation.md#bundled-configuration).
371+
It's your responsibility to make sure the extensions you load are compiled/linked against a version of [SQLite](https://www.sqlite.org/) that is compatible with `better-sqlite3`. Keep in mind that new versions of `better-sqlite3` will periodically use newer versions of [SQLite](https://www.sqlite.org/). You can see which version is being used [here](./compilation.md#bundled-configuration).
372372

373373
```js
374374
db.loadExtension('./my-extensions/compress.so');
@@ -421,7 +421,7 @@ An object representing a single SQL statement.
421421
- [Statement#bind()](#bindbindparameters---this)
422422
- [Properties](#properties-1)
423423

424-
> NOTE: Statements are [finalized](https://www.sqlite.org/c3ref/finalize.html) when garbage collected so there is no explicit API for it. Statements are also finalized when the associated database is closed.
424+
> NOTE: If you've used the [SQLite C API](https://www.sqlite.org/c3ref), you might except there to be a ["finalize"](https://www.sqlite.org/c3ref/finalize.html) method, but `better-sqlite3` automatically handles this during garbage collection (or when the associated database is closed).
425425
426426
### .run([*...bindParameters*]) -> *object*
427427

@@ -608,11 +608,11 @@ console.log(cat.name); // => "Joey"
608608

609609
# class *SqliteError*
610610

611-
Whenever an error occurs within SQLite3, a `SqliteError` object will be thrown. `SqliteError` is a subclass of `Error`. Every `SqliteError` object has a `code` property, which is a string matching one of the "extended result codes" defined [here](https://sqlite.org/rescode.html) (for example, `"SQLITE_CONSTRAINT_UNIQUE"`).
611+
Whenever an error occurs within SQLite, a `SqliteError` object will be thrown. `SqliteError` is a subclass of `Error`. Every `SqliteError` object has a `code` property, which is a string matching one of the "extended result codes" defined [here](https://sqlite.org/rescode.html) (for example, `"SQLITE_CONSTRAINT_UNIQUE"`).
612612

613-
If you receive a `SqliteError`, it probably means you're using SQLite3 incorrectly. The error didn't originate in `better-sqlite3`, so it's probably not an issue with `better-sqlite3`. It's recommended that you learn about the meaning of the error [here](https://sqlite.org/rescode.html), and perhaps learn more about how to use SQLite3 by reading [their docs](https://sqlite.org/docs.html).
613+
If you receive a `SqliteError`, it probably means you're using SQLite incorrectly. The error didn't originate in `better-sqlite3`, so it's probably not an issue with `better-sqlite3`. It's recommended that you learn about the meaning of the error [here](https://sqlite.org/rescode.html), and perhaps learn more about how to use SQLite by reading [their docs](https://sqlite.org/docs.html).
614614

615-
> In the unlikely scenario that SQLite3 throws an error that is not recognized by `better-sqlite3` (this would be considered a bug in `better-sqlite3`), the `code` property will be `"UNKNOWN_SQLITE_ERROR_NNNN"`, where `NNNN` is the numeric error code. If this happens to you, please report it as an [issue](https://github.com/JoshuaWise/better-sqlite3/issues).
615+
> In the unlikely scenario that SQLite throws an error that is not recognized by `better-sqlite3` (this would be considered a bug in `better-sqlite3`), the `code` property will be `"UNKNOWN_SQLITE_ERROR_NNNN"`, where `NNNN` is the numeric error code. If this happens to you, please report it as an [issue](https://github.com/JoshuaWise/better-sqlite3/issues).
616616
617617
# Binding Parameters
618618

@@ -629,7 +629,7 @@ stmt.run(['John', 'Smith', 45]);
629629
stmt.run(['John'], ['Smith', 45]);
630630
```
631631

632-
You can also use named parameters. SQLite3 provides [3 different syntaxes for named parameters](https://www.sqlite.org/lang_expr.html) (`@foo`, `:foo`, and `$foo`), all of which are supported by `better-sqlite3`.
632+
You can also use named parameters. SQLite provides [3 different syntaxes for named parameters](https://www.sqlite.org/lang_expr.html) (`@foo`, `:foo`, and `$foo`), all of which are supported by `better-sqlite3`.
633633

634634
```js
635635
// The following are equivalent.
@@ -652,9 +652,9 @@ const stmt = db.prepare('INSERT INTO people VALUES (@name, @name, ?)');
652652
stmt.run(45, { name: 'Henry' });
653653
```
654654

655-
Here is how `better-sqlite3` converts values between SQLite3 and JavaScript:
655+
Here is how `better-sqlite3` converts values between SQLite and JavaScript:
656656

657-
|SQLite3|JavaScript|
657+
|SQLite|JavaScript|
658658
|---|---|
659659
|`NULL`|`null`|
660660
|`REAL`|`number`|

0 commit comments

Comments
 (0)