index.js
/**
 * This function will load from the database, 'size' number of records into queue array
 * @param {PersistentQueue} q Instance of queue
 * @param size How many records to hydrate
 */
This function will load from the database, 'size' number of records into queue array
@param {PersistentQueue} q Instance of queue
@param size How many records to hydrate
This function will load from the database ' size ' number of records into queue array @param { PersistentQueue } q Instance of queue @param size How many records to hydrate
function hydrateQueue(q, size) { 
	if(q.debug) console.log('HydrateQueue') ;
	return new Promise((resolve, reject) => {
		if(q.db === null)
			reject('Open queue database before starting queue') ;
		q.db.all('SELECT * FROM ' + table + ' ORDER BY id ASC LIMIT ' + q.batchSize, (err, jobs) => {
			if(err !== null)
				reject(err) ;
			if(q.debug) {
				for(let i = 0 ; i < jobs.length ; i++)
					if(q.debug) console.log(JSON.stringify(jobs[i])) ;
			}
			q.queue = jobs.map(job => {
				try {
					return { id: job.id, job: JSON.parse(job.job)} ;
				}
				catch(err) {
					reject(err) ;
				}
			}) ;
			resolve(jobs) ;
		}) ;
	}) ;
}
function hydrateQueue ( q , size ) { if ( q . debug ) console . log ( 'HydrateQueue' ) ; return new Promise ( ( resolve , reject ) => { if ( q . db === null ) reject ( 'Open queue database before starting queue' ) ; q . db . all ( 'SELECT * FROM ' + table + ' ORDER BY id ASC LIMIT ' + q . batchSize , ( err , jobs ) => { if ( err !== null ) reject ( err ) ; if ( q . debug ) { for ( let i = 0 ; i < jobs . length ; i ++ ) if ( q . debug ) console . log ( JSON . stringify ( jobs [ i ] ) ) ; } q . queue = jobs . map ( job => { try { return { id : job . id , job : JSON . parse ( job . job ) } ; } catch ( err ) { reject ( err ) ; } } ) ; resolve ( jobs ) ; } ) ; } ) ; }
This function will load from the database, 'size' number of records into queue array
 @param {PersistentQueue} q Instance of queue
 @param size How many records to hydrate
This function will load from the database ' size ' number of records into queue array @param { PersistentQueue } q Instance of queue @param size How many records to hydrate
// eslint-disable-line no-unused-vars // Update our queue array (converting stored string back to object using JSON.parse