Database Drivers
Verse supports many different databases through database driver plugins.
Supported Database Drivers
Verse currently supports the following database drivers:
Database | Package | Function |
---|---|---|
PostgreSQL | @operativa/verse-postgres | postgres |
MySQL | @operativa/verse-mysql | mysql |
SQLite | @operativa/verse-sqlite | sqlite |
SQL Server | @operativa/verse-mssql | mssql |
Oracle | @operativa/verse-oracle | oracle |
Using a Database Driver
To use a database driver:
- install the package for the database you want to use
- add the import for the driver
- add the driver to your verse function
In this example, we would like to use SQLite.
You would install the SQLite driver, @operativa/verse-sqlite
:
- npm
- Yarn
- pnpm
npm install @operativa/verse-sqlite
yarn add @operativa/verse-sqlite
pnpm add @operativa/verse-sqlite
You would then add the import for the driver and initialize it in your verse function:
import { verse } from "@operativa/verse";
import { sqlite } from "@operativa/verse-sqlite";
import { boolean, entity, int, string } from "@operativa/verse/model/builder";
const db = verse({
config: {
driver: sqlite("todos.sqlite"),
},
model: {
entities: {
todos: entity({
id: int(),
title: string(),
completed: boolean(),
}),
},
},
});