Socket
Socket
Sign inDemoInstall

better-sqlite3

Package Overview
Dependencies
Maintainers
1
Versions
129
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

better-sqlite3 - npm Package Compare versions

Comparing version 0.10.1 to 0.10.2

4

package.json
{
"name": "better-sqlite3",
"version": "0.10.1",
"description": "The fastest and most carefully designed library for SQLite3 in Node.js.",
"version": "0.10.2",
"description": "The fastest and simplest library for SQLite3 in Node.js.",
"homepage": "http://github.com/JoshuaWise/better-sqlite3",

@@ -6,0 +6,0 @@ "author": "Joshua Wise <joshuathomaswise@gmail.com>",

# better-sqlite3 [![Build Status](https://travis-ci.org/JoshuaWise/better-sqlite3.svg?branch=master)](https://travis-ci.org/JoshuaWise/better-sqlite3)
The fastest and most carefully designed library for SQLite3 in Node.js.
The fastest and simplest library for SQLite3 in Node.js.
- Full transaction support
- Geared for performance and efficiency
- Idiomatic synchronous API
- Easy-to-use synchronous API *(faster than an asynchronous API... yes, you read that correctly)*

@@ -24,3 +24,3 @@ ## Installation

console.log(row.firstName, row.lastName, row.email);
})
});
```

@@ -42,16 +42,18 @@

If the database is closed, the `close` event will be fired. If the database was closed because of an error, the associated `Error` object will be available as the first parameter of the `close` event. If there was no error, the first parameter will be `null`.
If the database is closed, the `close` event will be fired. If an error occured while trying to open or close the database, the associated `Error` object will be available as the first parameter of the `close` event. If there was no error, the first parameter will be `null`.
If `options.memory` is `true`, an in-memory database will be created, rather than a disk-bound one. Default is `false`.
### .statement(string) -> Statement
### .statement(*string*) -> *Statement*
Creates a new prepared [`Statement`](#class-statement) object. This method will throw an exception if the provided string is not a valid SQL statement.
Creates a new prepared [`Statement`](#class-statement) from the given SQL string.
### .transaction(arrayOfStrings) -> Transaction
### .transaction(*arrayOfStrings*) -> *Transaction*
Creates a new prepared [`Transaction`](#class-transaction) object. Each string in the given array must be a valid SQL statement. [`Transaction`](#class-transaction) objects cannot contain read-only statements. In `better-sqlite3`, transactions serve the sole purpose of batch-write operations. For read-only operations, use regular [prepared statements](#statementstring---statement).
Creates a new prepared [`Transaction`](#class-transaction) from the given array of SQL strings.
### .pragma(string, [simplify]) -> results
*NOTE:* [`Transaction`](#class-transaction) objects cannot contain read-only statements. In `better-sqlite3`, transactions serve the sole purpose of batch-write operations. For read-only operations, use regular [prepared statements](#statementstring---statement). This restriction may change in the future.
### .pragma(*string*, [*simplify*]) -> *results*
Executes the given PRAGMA and return its result. By default, the return value will be an array of result rows. Each row is represented by an object whose keys correspond to column names.

@@ -68,5 +70,5 @@

It's better to use this method instead of normal [prepared statements](#statementstring---statement) when executing PRAGMA, because this method normalizes some odd behavior that may otherwise be experienced. The documentation on SQLite3 PRAGMA statements can be found [here](https://www.sqlite.org/pragma.html).
It's better to use this method instead of normal [prepared statements](#statementstring---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).
### .checkpoint([force]) -> number
### .checkpoint([*force*]) -> *number*

@@ -77,15 +79,15 @@ Runs a [WAL mode checkpoint](https://www.sqlite.org/wal.html).

When the operation is complete, it returns a number between `0` and `1`, indicating the fraction of the WAL file that was checkpointed. For forceful checkpoints ("RESTART" mode), this number will always be `1` unless there is no WAL file.
When the operation is complete, it returns a number between `0` and `1`, indicating the fraction of the WAL file that was checkpointed. For forceful checkpoints ("RESTART" mode), this number will always be `1` unless there was no WAL file to begin with.
If execution of the checkpoint fails, an `Error` is thrown.
### .close() -> this
### .close() -> *this*
Closes the database connection. After invoking this method, no statements/transactions can be created or executed. When all resources have been released, the `close` event will be fired.
### *get* .open -> boolean
### *get* .open -> *boolean*
Returns whether the database is currently open.
### *get* .name -> string
### *get* .name -> *string*

@@ -98,3 +100,3 @@ Returns the string that was used to open the databse connection.

### .run([...bindParameters]) -> object
### .run([*...bindParameters*]) -> *object*

@@ -110,35 +112,35 @@ **(only on write statements)*

You can optionally specify [bind parameters](#binding-parameters), which are only bound for the given execution.
You can specify [bind parameters](#binding-parameters), which are only bound for the given execution.
### .get([...bindParameters]) -> row
### .get([*...bindParameters*]) -> *row*
**(only on read-only statements)*
Executes the prepared statement. When execution completes it returns an object that represents the first row retrieved by the query. The object's keys represent column names. If the statement was successful but retrieved no data, `undefined` is returned instead.
Executes the prepared statement. When execution completes it returns an object that represents the first row retrieved by the query. The object's keys represent column names.
If execution of the statement fails, an `Error` is thrown.
If the statement was successful but found no data, `undefined` is returned. If execution of the statement fails, an `Error` is thrown.
You can optionally specify [bind parameters](#binding-parameters), which are only bound for the given execution.
You can specify [bind parameters](#binding-parameters), which are only bound for the given execution.
### .all([...bindParameters]) -> array of rows
### .all([*...bindParameters*]) -> *array of rows*
**(only on read-only statements)*
Similar to [`.get()`](#getbindparameters---row), but instead of only retrieving one row all matching rows will be retrieved. The return value is an array of row objects. If no rows are retrieved, the array will be empty.
Similar to [`.get()`](#getbindparameters---row), but instead of only retrieving one row all matching rows will be retrieved. The return value is an array of row objects.
If execution of the statement fails, an `Error` is thrown.
If no rows are found, the array will be empty. If execution of the statement fails, an `Error` is thrown.
You can optionally specify [bind parameters](#binding-parameters), which are only bound for the given execution.
You can specify [bind parameters](#binding-parameters), which are only bound for the given execution.
### .each([...bindParameters], callback) -> undefined
### .each([*...bindParameters*], callback) -> *undefined*
**(only on read-only statements)*
Similar to [`.all()`](#allbindparameters---array-of-rows), but instead of returning every row together, the `callback` is invoked for each row as they are retrieved, one by one. After all rows have been consumed, `undefined` is returned.
Similar to [`.all()`](#allbindparameters---array-of-rows), but instead of returning every row together, the `callback` is invoked for each row as they are retrieved, one by one.
If execution of the statement fails, an `Error` is thrown and iteration stops.
After all rows have been consumed, `undefined` is returned. If execution of the statement fails, an `Error` is thrown and iteration stops.
You can optionally specify [bind parameters](#binding-parameters), which are only bound for the given execution.
You can specify [bind parameters](#binding-parameters), which are only bound for the given execution.
### .pluck() -> this
### .pluck() -> *this*

@@ -151,3 +153,3 @@ **(only on read-only statements)*

### .bind([...bindParameters]) -> this
### .bind([*...bindParameters*]) -> *this*

@@ -158,9 +160,9 @@ [Binds the given parameters](#binding-parameters) to the statement *permanently*. Unlike binding parameters upon execution, these parameters will stay bound to the prepared statement for its entire life.

This method is primarily used as a performance optimization when you need to execute the same prepared statement many times with the same bound parameters.
This method is primarily used as a performance optimization when you need to execute the same prepared statement many times with the same bound parameters. However, if the prepared statement will only be executed once, it's faster to bind the parameters directly with the execution ([`run()`](#runbindparameters---object), [`get()`](#getbindparameters---row), [`all()`](#allbindparameters---array-of-rows), or [`each()`](#eachbindparameters-callback---undefined)).
### *get* .source -> string
### *get* .source -> *string*
Returns the source string that was used to create the prepared statement.
### *get* .readonly -> boolean
### *get* .readonly -> *boolean*

@@ -173,3 +175,3 @@ Returns whether the prepared statement is read-only.

### .run([...bindParameters]) -> object
### .run([*...bindParameters*]) -> *object*

@@ -187,9 +189,9 @@ Similar to [`Statement#run()`](#runbindparameters---object).

You can optionally specify [bind parameters](#binding-parameters), which are only bound for the given execution.
You can specify [bind parameters](#binding-parameters), which are only bound for the given execution.
### .bind([...bindParameters]) -> this
### .bind([*...bindParameters*]) -> *this*
Same as [`Statement#bind()`](#bindbindparameters---this).
### *get* .source -> string
### *get* .source -> *string*

@@ -201,3 +203,3 @@ Returns a concatenation of every source string that was used to create the prepared transaction. The source strings are seperated by newline characters (`\n`).

This section applies to anywhere in the documentation that specifies the optional argument `[...bindParameters]`.
This section refers to anywhere in the documentation that specifies the optional argument [*`...bindParameters`*].

@@ -215,3 +217,3 @@ There are many ways to bind parameters to a prepared statement or transaction. The simplest way is with anonymous parameters:

You can also use named parameters. SQLite3 provides [4 different syntaxes for named parameters](https://www.sqlite.org/lang_expr.html), three of which are supported by `better-sqlite3` (`@foo`, `:foo`, and `$foo`). However, if you use named parameters, make sure to only use **one** syntax within a given [`Statement`](#class-statement) or [`Transaction`](#class-transaction) object. Mixing syntaxes within the same object is not supported.
You can also use named parameters. SQLite3 provides [4 different syntaxes for named parameters](https://www.sqlite.org/lang_expr.html), **three** of which are supported by `better-sqlite3` (`@foo`, `:foo`, and `$foo`). However, if you use named parameters, make sure to only use **one** syntax within a given [`Statement`](#class-statement) or [`Transaction`](#class-transaction) object. Mixing syntaxes within the same object is not supported.

@@ -218,0 +220,0 @@ ```js

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc