-
-
Notifications
You must be signed in to change notification settings - Fork 15
Description
Is your feature request related to a problem? Please describe.
With recent updates to the Bun runtime, they have introduced a native, high-performance SQL driver (Bun.sql) specifically for PostgreSQL. Currently, to use Orchid ORM with Bun, we still rely on third-party Node.js drivers like pg or postgres.js.
While these work well, they do not take full advantage of the Bun runtime's potential.
Describe the solution you'd like
I would love to see a native adapter added to Orchid ORM that utilizes Bun.sql.
Since Bun.sql is built-in to the runtime, this would offer two main benefits:
- Performance: Bun claims their native implementation is significantly faster than existing Node.js drivers.
- Zero Dependencies: It removes the need to install
pgorpostgres.jsas dependencies in the project.
Proposed Usage
Ideally, it would look something like this in the configuration:
import { OrchidORM } from 'orchid-orm';
import { BunSqlAdapter } from 'orchid-orm/adapter-bun-sql'; // Proposed new adapter
export const db = new OrchidORM({
adapter: new BunSqlAdapter({
url: process.env.DATABASE_URL,
// Bun specific options
max: 20,
idleTimeout: 30,
}),
});Additional Context
- Bun SQL Documentation: https://bun.sh/docs/api/sql
- The API for
Bun.sqlis relatively simple and supports prepared statements, which should map well to Orchid's internal query building structure.
Describe alternatives you've considered
The current alternative is continuing to use postgres.js or node-postgres. While stable, this misses out on the optimization opportunities provided by the native Bun environment.