First, add the
grind-db package via your preferred package manager:
yarn add grind-db
Next, you’ll need to add
DatabaseProvider to your app providers in
const app =appproviders
In order to actually use a database, you’ll first need to install the database driver(s) you need. Knex supports a variety of different drivers:
yarn add mysql2yarn add mariasqlyarn add sqlite3yarn add pg
The default database connection is exposed via
app.db. For full details on how the query builder works, head over to the knex.js documentation.
Your database config should live in
Here’s an example of a config file that supports both MariaDB and SQLite:
default key tells the Database provider which connection it should load by default.