forked from keystonejs/keystone
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
51 changed files
with
1,470 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"releases": [ | ||
{ "name": "@voussoir/fields", "type": "minor" }, | ||
{ "name": "@voussoir/test-utils", "type": "minor" }, | ||
{ "name": "@voussoir/cypress-project-basic", "type": "minor" } | ||
], | ||
"dependents": [ | ||
{ | ||
"name": "@voussoir/cypress-project-access-control", | ||
"type": "patch", | ||
"dependencies": ["@voussoir/fields", "@voussoir/test-utils"] | ||
}, | ||
{ | ||
"name": "@voussoir/cypress-project-login", | ||
"type": "patch", | ||
"dependencies": ["@voussoir/fields", "@voussoir/test-utils"] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
- Add support for the Knex adapter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
**/*.md | ||
**/*.test.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# Keystone 5 Knex Database Adapter | ||
|
||
The [Knex](https://knexjs.org/#changelog) adapter is a general purpose adapter which can be used to connect to a range of different database backends. | ||
At present, the only fully supported backend is `Postgres`, however knex gives the potential for `MSSQL`, `MySQL`, `MariaDB`, `SQLite3`, `Oracle`, and `Amazon Redshift` to be supported. | ||
|
||
## Setting Up Your Database | ||
|
||
Before running Keystone, you must set up a database, a schema, and a user. | ||
|
||
```shell | ||
createdb -U postgres ks5_dev | ||
psql ks5_dev -U postgres -c "CREATE SCHEMA keystone;" | ||
psql ks5_dev -U postgres -c "CREATE USER keystone5 PASSWORD 'k3yst0n3'" | ||
psql ks5_dev -U postgres -c "GRANT ALL ON SCHEMA keystone TO keystone5;" | ||
``` | ||
|
||
## Usage | ||
|
||
```javascript | ||
const { KnexAdapter } = require('@keystonejs/adapter-knex'); | ||
|
||
const keystone = new Keystone({ | ||
name: 'My Awesome Project', | ||
adapter: new KnexAdapter(), | ||
}); | ||
|
||
const client = 'postgres'; | ||
const connection = 'postgres://keystone5:[email protected]:5432/ks5_dev'; | ||
const schemaName = 'keystone'; | ||
|
||
const knexOptions = { ... }; | ||
|
||
keystone.connect( | ||
client, | ||
connection, | ||
schemaName, | ||
...knexOptions, | ||
); | ||
``` | ||
|
||
## API | ||
|
||
### `client` | ||
|
||
_**Default:**_ `'postgres'` | ||
|
||
Defines the type of backend to use. Current `postgres` is supported, but any value supported by Knex may be supported in the future. | ||
|
||
### `connection` | ||
|
||
_**Default:**_ `'postgres://keystone5:[email protected]:5432/ks5_dev'` | ||
|
||
Either a connection string, or a connection object, as accepted by knex. | ||
See [knex docs](https://knexjs.org/#Installation-client) for more details. | ||
If the environment variable `KNEX_URI` is set, its value will be used as the default. | ||
|
||
### `schemaName` | ||
|
||
_**Default:**_ `'keystone'` | ||
|
||
All keystone tables are grouped within a schema. This value should match the name of the schema used in the `CREATE SCHEMA` step above. | ||
|
||
### `knexOptions` | ||
|
||
Any extra options provided will be passed through to the knex configuration function. See the [Knex docs](https://knexjs.org/#Installation-client) for possible values. | ||
|
||
## Debugging | ||
|
||
To log all knex queries, run the server with the environment variable `DEBUG=knex:query`. |
Oops, something went wrong.