https://github.com/necessarylion/bun-spark
Orm for bun
https://github.com/necessarylion/bun-spark
bun-orm bun-sqlite-orm postgres-orm query-builder-bun sqlite-orm
Last synced: 4 months ago
JSON representation
Orm for bun
- Host: GitHub
- URL: https://github.com/necessarylion/bun-spark
- Owner: necessarylion
- License: mit
- Created: 2025-08-02T06:13:08.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2025-08-20T02:28:08.000Z (4 months ago)
- Last Synced: 2025-08-30T06:33:40.502Z (4 months ago)
- Topics: bun-orm, bun-sqlite-orm, postgres-orm, query-builder-bun, sqlite-orm
- Language: TypeScript
- Homepage:
- Size: 816 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Bun Spark (sql query builder for bun)
A lightweight, type-safe query builder for Bun. Built with performance and developer experience in mind.
## [Documentation](https://necessarylion.github.io/bun-spark)
## Supported Drivers
- PostgreSQL
- SQLite
## Features
- **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
## Installation
```bash
bun add bun-spark
```
## Quick Start
### 1. Setup Database Connection
```typescript
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)
```
### Examples Queries
```typescript
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()
```
## Development
### Running Tests
```bash
# Run all tests
bun test
# Run specific test file
bun test test/select.test.ts
```
### Environment Setup
Set up your test database environment variables:
```bash
touch .env
```
```bash
DB_HOST=localhost
DB_PORT=5432
DB_NAME=bun_orm
DB_USER=postgres
DB_PASSWORD=postgres
```
## Contributing
1. Fork the repository
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'Add some amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request