0.65.1 • Published 5 months ago

@zerva/sqlite-bun v0.65.1

Weekly downloads
-
License
MIT
Repository
-
Last release
5 months ago

🌱 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

Visual Database Design

Support for DrawDB planned.

Links

Inspirations and alternatives:

0.65.1

5 months ago

0.64.0

8 months ago

0.63.0

8 months ago

0.59.0

10 months ago

0.59.1

10 months ago

0.58.2

10 months ago

0.62.0

9 months ago

0.61.0

9 months ago

0.60.0

10 months ago

0.57.0

10 months ago

0.56.0

12 months ago

0.55.3

12 months ago