@storecraft/database-sqlite
v1.3.0
Published
Official SQLite Database driver for storecraft
Maintainers
Readme
Storecraft SQLite driver
Official SQLite driver for StoreCraft using better-sqlite package.
npm i @storecraft/database-sqliteusage
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]'],
}
)
.withPlatform(new NodePlatform())
.withDatabase(
new SQLite(
{
filepath: join(homedir(), 'db.sqlite')
}
)
)
.withStorage(new NodeLocalStorage())
.init();
await migrateToLatest(app.__show_me_everything.db, false);
http.createServer(app.handler).listen(
8000,
() => {
app.print_banner('http://localhost:8000');
}
); Storecraft will search the following env variables
SQLITE_FILEPATH=./data.dbSo, you can instantiate with empty config
.withDatabase(
new SQLite()
)Testing Locally
Simply run tests/runner.test.js
npm run database-sqlite:testAuthor: Tomer Shalev <[email protected]>