1+ import { MongoClient } from 'mongodb' ;
2+ import { createMongoQueue } from './dist/adapters/mongodb.js' ;
3+
4+ // Simple debug script to test MongoDB adapter
5+ async function debugMongo ( ) {
6+ const client = new MongoClient ( 'mongodb://localhost:27017' ) ;
7+ await client . connect ( ) ;
8+
9+ const queue = createMongoQueue ( client , 'debug_test' , 'jobs' ) ;
10+
11+ console . log ( '1. Adding a job...' ) ;
12+ const jobId = await queue . addJob ( 'test-job' , { payload : { data : 'debug test' } } ) ;
13+ console . log ( 'Job added with ID:' , jobId ) ;
14+
15+ console . log ( '2. Checking job status...' ) ;
16+ const status = await queue . status ( jobId ) ;
17+ console . log ( 'Job status:' , status ) ;
18+
19+ console . log ( '3. Checking database directly...' ) ;
20+ const db = client . db ( 'debug_test' ) ;
21+ const collection = db . collection ( 'jobs' ) ;
22+ const jobs = await collection . find ( { } ) . toArray ( ) ;
23+ console . log ( 'Jobs in database:' , jobs . length ) ;
24+ console . log ( 'First job:' , JSON . stringify ( jobs [ 0 ] , null , 2 ) ) ;
25+
26+ console . log ( '4. Trying to reserve a job...' ) ;
27+ const adapter = queue . db ;
28+ const reserved = await adapter . reserveJob ( 5 ) ;
29+ console . log ( 'Reserved job:' , reserved ) ;
30+
31+ await client . close ( ) ;
32+ }
33+
34+ debugMongo ( ) . catch ( console . error ) ;
0 commit comments