A lightweight, type-safe query builder for Bun. Built with performance and developer experience in mind.
- PostgreSQL
- SQLite
- Fast: Built on Bun's high-performance runtime
- Type-safe: Full TypeScript support with comprehensive type definitions and compile-time null/undefined prevention
- Simple: Intuitive query builder API
- Transactions: Full transaction support with automatic rollback
- Tested: Comprehensive test suite with real database integration
bun add bun-spark
import { spark } from 'bun-spark'
const db = spark({
driver: 'postgresql',
host: 'localhost',
port: 5432,
database: 'my_database',
username: 'postgres',
password: 'password'
})
// `db` is a query builder instance
const isConnected = await db.testConnection()
console.log('Connected:', isConnected)
const users = await db.table('users').select(['name', 'email']).get()
const users = await db
.table('users')
.where('active', '=', true)
.where('age', '>', 25)
.get()
const firstUser = await db
.table('users')
.where('id', '=', 1)
.first()
# Run all tests
bun test
# Run specific test file
bun test test/select.test.ts
Set up your test database environment variables:
touch .env
DB_HOST=localhost
DB_PORT=5432
DB_NAME=bun_orm
DB_USER=postgres
DB_PASSWORD=postgres
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request