@storecraft/database-sqlite
v1.0.7
Published
Official SQLite Database driver for storecraft
Downloads
129
Maintainers
Readme
Storecraft SQLite
driver
Official SQLite
driver for StoreCraft
using better-sqlite
package.
npm i @storecraft/database-sqlite
usage
import 'dotenv/config';
import http from "node:http";
import { App } from '@storecraft/core'
import { NodePlatform } from '@storecraft/core/platform/node';
import { NodeLocalStorage } from '@storecraft/core/storage/node'
import { SQLite } from '@storecraft/database-sqlite'
import { migrateToLatest } from '@storecraft/database-sqlite/migrate.js'
const app = new App(
{
auth_admins_emails: ['[email protected]'],
auth_secret_access_token: 'auth_secret_access_token',
auth_secret_refresh_token: 'auth_secret_refresh_token'
}
)
.withPlatform(new NodePlatform())
.withDatabase(
new SQLite(
{
filepath: join(homedir(), 'db.sqlite')
}
)
)
.withStorage(new NodeLocalStorage())
await app.init();
await migrateToLatest(app.db, false);
const server = http.createServer(app.handler).listen(
8000,
() => {
console.log(`Server is running on http://localhost:8000`);
}
);
Testing Locally
Simply run tests/runner.test.js
npm run database-sqlite:test
Author: Tomer Shalev <[email protected]>