Database
Last updated
Was this helpful?
Last updated
Was this helpful?
Novel makes use of PostgreSQL exclusively because it has very wide adoption across cloud and a vibrant plugin community.
Knex.js with Objection.js is the ORM of choice for the project.
To install PostgreSQL, follow the tutorial.
If you have not followed the Getting started tutorial, it would be best to start with that
Your Novel instance will use the environment variable below to create a connection pool against your database.
Prisma uses a different DSL that you most likely would not touch frequently. It also has abstraction overhead and troubleshooting issues due to having a different runtime engine.
Drizzle has a smaller community but with comparable pedigree as knex
TypeORM is more of an ORM but also suffers from abstraction overhead. It has better support for typescript than knex.
Kysely is a newer player and have a smaller community similar to Drizzle.
Novel ships with default database tables that function as a foundation for all the relevant features you have access to.
These are located in /packages/novel/migrations
.
These migrations are executed during development runtime as well as when you start the server.
You can use the internal database connection like below
You can use knex methods here.
You can create a request bound transaction
All database calls within the request lifecycle uses the transaction.
These models follows the multi-tenancy principle. These are also covered under warranty and not advised to be overwritten.
These models are located in /packages/novel/models/
.
A deeper discussion and explanation of the way models work are explained below
2024-12-20 - Initial Documentation
There are a lot of tools out there you can use to connec to your database. What we recommend is , or .