@zerva/sqlite v0.54.0
🌱 Zerva useSqliteDatabase
This is a side project of Zerva
SQLite abstraction
Installation
npm install @zerva/sqlite
Help
Use better-sqlite3 through a simplified abstraction layer.
A principle followed here to keep life easy with databases is: Never delete something, in particular no columns!
import { useSqliteDatabase } from '@zerva/sqlite'
// Open / create the database
const db = useSqliteDatabase('test.sqlite')
// Get typed results
interface Person {
id: number
name: string
age: number
}
// Create table only if not exists
// Colums that did not exist before are added
// Colums that are not defined but did exist remain untouched
const table = db.table<Person>('person', {
name: 'text',
age: 'integer',
})
// Create index, if not existed before
table.index('name')
// Insert
table.insert({
name: 'Doe',
age: 49,
})
// Get all rows
const allRows = table.all()
// Get one row
const doe = table.get(1)
// Directly do all you like do with BetterSQLite3
const betterSQLiteDatabase = db.db
Links
Inspirations and alternatives:
15 days ago
30 days ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
2 months ago
3 months ago
4 months ago
4 months ago
5 months ago
6 months ago
6 months ago
6 months ago
8 months ago
6 months ago
8 months ago
7 months ago
10 months ago
11 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago