Skip to content

Commit c942cc4

Browse files
committed
docs(readme): add knex information
1 parent d07c587 commit c942cc4

1 file changed

Lines changed: 33 additions & 1 deletion

File tree

README.md

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ npm install @boringnode/queue
1010

1111
## Features
1212

13-
- **Multiple Queue Adapters**: Support for Redis (production) and Sync (testing/development)
13+
- **Multiple Queue Adapters**: Support for Redis, Knex (PostgreSQL, MySQL, SQLite), and Sync
1414
- **Type-Safe Jobs**: Define jobs as TypeScript classes with typed payloads
1515
- **Delayed Jobs**: Schedule jobs to run after a specific delay
1616
- **Multiple Queues**: Organize jobs into different queues for better organization
@@ -173,6 +173,38 @@ import { sync } from '@boringnode/queue/drivers/sync_adapter'
173173
const adapter = sync()
174174
```
175175

176+
### Knex Adapter
177+
178+
For SQL databases (PostgreSQL, MySQL, SQLite) using Knex:
179+
180+
```typescript
181+
import { knex } from '@boringnode/queue/drivers/knex_adapter'
182+
183+
// With configuration (adapter manages connection lifecycle)
184+
const adapter = knex({
185+
client: 'pg',
186+
connection: {
187+
host: 'localhost',
188+
port: 5432,
189+
user: 'postgres',
190+
password: 'postgres',
191+
database: 'myapp',
192+
},
193+
})
194+
195+
// Or with an existing Knex instance (you manage connection lifecycle)
196+
import Knex from 'knex'
197+
198+
const connection = Knex({ client: 'pg', connection: '...' })
199+
const adapter = knex(connection)
200+
```
201+
202+
The adapter automatically creates the `queue_jobs` table on first use. You can customize the table name:
203+
204+
```typescript
205+
const adapter = knex(config, 'custom_jobs_table')
206+
```
207+
176208
## Worker Configuration
177209

178210
Workers process jobs from one or more queues:

0 commit comments

Comments
 (0)