Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add better-sqlite3 driver #6224

Merged
merged 1 commit into from Jul 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 10 additions & 1 deletion docs/connection-options.md
Expand Up @@ -5,6 +5,7 @@
* [`mysql` / `mariadb` connection options](#mysql--mariadb-connection-options)
* [`postgres` / `cockroachdb` connection options](#postgres--cockroachdb-connection-options)
* [`sqlite` connection options](#sqlite-connection-options)
* [`better-sqlite3` connection options](#better-sqlite3-connection-options)
* [`cordova` connection options](#cordova-connection-options)
* [`react-native` connection options](#react-native-connection-options)
* [`nativescript` connection options](#nativescript-connection-options)
Expand All @@ -22,7 +23,7 @@ Connection options is a connection configuration you pass to `createConnection`
## Common connection options

* `type` - Database type. You must specify what database engine you use.
Possible values are "mysql", "postgres", "cockroachdb", "mariadb", "sqlite", "cordova", "nativescript",
Possible values are "mysql", "postgres", "cockroachdb", "mariadb", "sqlite", "better-sqlite3", "cordova", "nativescript",
"oracle", "mssql", "mongodb", "sqljs", "react-native".
This option is **required**.

Expand Down Expand Up @@ -185,6 +186,14 @@ See [SSL options](https://github.com/mysqljs/mysql#ssl-options).

* `database` - Database path. For example "./mydb.sql"

## `better-sqlite3` connection options

* `database` - Database path. For example "./mydb.sql"

* `statementCacheSize` - Cache size of sqlite statement to speed up queries (default 100).

* `prepareDatabase` - Function to run before a database is used in typeorm. You can access original better-sqlite3 Database object here.

## `cordova` connection options

* `database` - Database name
Expand Down
11 changes: 10 additions & 1 deletion docs/zh_CN/connection-options.md
Expand Up @@ -5,6 +5,7 @@
- [`mysql`/`mariadb`](#mysql/mariadb)
- [`postgres`/`cockroachdb`连接选项](#postgres/cockroachdb连接选项)
- [`sqlite`](#sqlite)
- [`better-sqlite3`](#better-sqlite3)
- [`cordova`](#cordova)
- [`react-native`](#react-native)
- [`nativescript`](#nativescript)
Expand All @@ -20,7 +21,7 @@

## 常用的连接选项

- `type` - 数据库类型。你必须指定要使用的数据库引擎。该值可以是"mysql","postgres","mariadb","sqlite","cordova","nativescript","oracle","mssql","mongodb","sqljs","react-native"。此选项是**必需**的。
- `type` - 数据库类型。你必须指定要使用的数据库引擎。该值可以是"mysql","postgres","mariadb","sqlite", "better-sqlite3","cordova","nativescript","oracle","mssql","mongodb","sqljs","react-native"。此选项是**必需**的。

- `name` - 连接名。 在使用 `getConnection(name: string)`
或 `ConnectionManager.get(name: string)`时候需要用到。不同连接的连接名称不能相同,它们都必须是唯一的。如果没有给出连接名称,那么它将被设置为"default"。
Expand Down Expand Up @@ -128,6 +129,14 @@

- `database` - 数据库路径。 例如 "./mydb.sql"

## `better-sqlite3`

* `database` - 数据库路径。 例如 "./mydb.sql"

* `statementCacheSize` - Sqlite 查询 Statement 缓存大小。默认100

* `prepareDatabase` - 在数据库投入使用前运行的函数。你可以在这里访问到better-sqlite3原始数据库对象。

## `cordova`

- `database` - 数据库名
Expand Down
6 changes: 6 additions & 0 deletions ormconfig.circleci-cockroach.json
Expand Up @@ -25,6 +25,12 @@
"type": "sqlite",
"database": "temp/sqlitedb.db"
},
{
"skip": true,
"name": "better-sqlite3",
"type": "better-sqlite3",
"database": "temp/better-sqlite3db.db"
},
{
"skip": true,
"name": "postgres",
Expand Down
6 changes: 6 additions & 0 deletions ormconfig.circleci-common.json
Expand Up @@ -25,6 +25,12 @@
"type": "sqlite",
"database": "temp/sqlitedb.db"
},
{
"skip": false,
"name": "better-sqlite3",
"type": "better-sqlite3",
"database": "temp/better-sqlite3db.db"
},
{
"skip": false,
"name": "postgres",
Expand Down
6 changes: 6 additions & 0 deletions ormconfig.circleci-oracle.json
Expand Up @@ -25,6 +25,12 @@
"type": "sqlite",
"database": "temp/sqlitedb.db"
},
{
"skip": true,
"name": "better-sqlite3",
"type": "better-sqlite3",
"database": "temp/better-sqlite3db.db"
},
{
"skip": true,
"name": "postgres",
Expand Down
7 changes: 7 additions & 0 deletions ormconfig.json.dist
Expand Up @@ -28,6 +28,13 @@
"database": "temp/sqlitedb.db",
"logging": false
},
{
"skip": false,
"name": "better-sqlite3",
"type": "better-sqlite3",
"database": "temp/better-sqlite3db.db",
"logging": false
},
{
"skip": false,
"name": "postgres",
Expand Down
7 changes: 7 additions & 0 deletions ormconfig.travis.json
Expand Up @@ -25,6 +25,13 @@
"type": "sqlite",
"database": "temp/sqlitedb.db"
},
{
"skip": false,
"name": "better-sqlite3",
"type": "better-sqlite3",
"database": "temp/better-sqlite3db.db",
"logging": false
},
{
"skip": false,
"name": "postgres",
Expand Down