From f05b8d74f2a8d8e962e8f98c938485355d09bd0a Mon Sep 17 00:00:00 2001 From: Shaun Brown <97027841+StrapiShaun@users.noreply.github.com> Date: Wed, 21 Sep 2022 14:00:38 +0200 Subject: [PATCH] Sqlite update (#1147) * create branch for sqlite update * add manual installation sqlite * Update docs/developer-docs/latest/setup-deployment-guides/configurations/databases/sqlite.md Co-authored-by: Shaun Brown <97027841+StrapiShaun@users.noreply.github.com> * Update docs/developer-docs/latest/setup-deployment-guides/configurations/databases/sqlite.md Co-authored-by: Shaun Brown <97027841+StrapiShaun@users.noreply.github.com> * add typescript and small improvements * change H2 heading Co-authored-by: quiloos39 Co-authored-by: Necdet Efe Co-authored-by: Pierre Wizla --- .../configurations/databases/sqlite.md | 32 +++++++++++++++++-- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/docs/developer-docs/latest/setup-deployment-guides/configurations/databases/sqlite.md b/docs/developer-docs/latest/setup-deployment-guides/configurations/databases/sqlite.md index ab2a8aed5f..3044226e28 100644 --- a/docs/developer-docs/latest/setup-deployment-guides/configurations/databases/sqlite.md +++ b/docs/developer-docs/latest/setup-deployment-guides/configurations/databases/sqlite.md @@ -8,7 +8,7 @@ canonicalUrl: https://docs.strapi.io/developer-docs/latest/setup-deployment-guid SQLite is the default ([Quick Start](/developer-docs/latest/getting-started/quick-start.md)) and recommended database to quickly create an app locally. -## Install SQLite using starter +## Install SQLite during app creation Use one of the following commands: @@ -36,17 +36,20 @@ The [Quick Start Guide](/developer-docs/latest/getting-started/quick-start.md) i ## Install SQLite manually -In terminal, run the following command: +In a terminal, run the following command: + ```sh npm install better-sqlite3 ``` + + ```sh yarn add better-sqlite3 ``` @@ -54,7 +57,10 @@ yarn add better-sqlite3 -Add the following to your `./config/database.js` file: +Add the following code to your `./config/database.js` or `./config/database.ts` file: + + + ```js module.exports = ({ env }) => ({ @@ -68,6 +74,26 @@ module.exports = ({ env }) => ({ }); ``` + + + +```ts +import path from 'path'; + +export default ({ env }) => ({ + connection: { + client: 'sqlite', + connection: { + filename: path.join(__dirname, '..', '..', env('DATABASE_FILENAME', '.tmp/data.db')), + }, + useNullAsDefault: true, + }, +}); +``` + + + + ## Other SQL Databases (PostgreSQL, MySQL) Refer to the [configuration section](/developer-docs/latest/setup-deployment-guides/configurations/required/databases.md) for all supported options to setup Strapi with your SQL database.