index.js
function removeJob(self,id) {
	if(id === undefined) {
		id = self.queue.shift().id ;
	}
	else {
		// Search queue for id and remove if exists
		for(var i=0;i<self.queue.length;i++) {
			if(self.queue[i].id === id) {
				self.queue.splice(i,1) ;
				break ;
			}
		}
	}

	return new Promise(function(resolve,reject) {
		if(self.db === null)
			reject('Open queue database before starting queue') ;

		if(self.debug) console.log('About to delete') ;
		if(self.debug) console.log('Removing job: '+id) ;
		if(self.debug) console.log('From table: '+table) ;
		if(self.debug) console.log('With queue length: '+self.length) ;
		self.db.run("DELETE FROM " + table + " WHERE id = ?", id, function(err) {
			if(err !== null)
				reject(err) ;

			if(this.changes) // Number of rows affected (0 == false)
				resolve(id) ;

			reject("Job id "+id+" was not removed from queue") ;
		});
	}) ;
}
function removeJob(self,id) {
	if(id === undefined) {
		id = self.queue.shift().id ;
	}
	else {
		// Search queue for id and remove if exists
		for(var i=0;i<self.queue.length;i++) {
			if(self.queue[i].id === id) {
				self.queue.splice(i,1) ;
				break ;
			}
		}
	}

	return new Promise(function(resolve,reject) {
		if(self.db === null)
			reject('Open queue database before starting queue') ;

		if(self.debug) console.log('About to delete') ;
		if(self.debug) console.log('Removing job: '+id) ;
		if(self.debug) console.log('From table: '+table) ;
		if(self.debug) console.log('With queue length: '+self.length) ;
		self.db.run("DELETE FROM " + table + " WHERE id = ?", id, function(err) {
			if(err !== null)
				reject(err) ;

			if(this.changes) // Number of rows affected (0 == false)
				resolve(id) ;

			reject("Job id "+id+" was not removed from queue") ;
		});
	}) ;
}
function removeJob ( self , id ) { if ( id === undefined ) { id = self . queue . shift ( ) . id ; } else { // Search queue for id and remove if exists for ( var i = 0 ; i < self . queue . length ; i ++ ) { if ( self . queue [ i ] . id === id ) { self . queue . splice ( i , 1 ) ; break ; } } } return new Promise ( function ( resolve , reject ) { if ( self . db === null ) reject ( 'Open queue database before starting queue' ) ; if ( self . debug ) console . log ( 'About to delete' ) ; if ( self . debug ) console . log ( 'Removing job: ' + id ) ; if ( self . debug ) console . log ( 'From table: ' + table ) ; if ( self . debug ) console . log ( 'With queue length: ' + self . length ) ; self . db . run ( "DELETE FROM " + table + " WHERE id = ?" , id , function ( err ) { if ( err !== null ) reject ( err ) ; if ( this . changes ) // Number of rows affected (0 == false) resolve ( id ) ; reject ( "Job id " + id + " was not removed from queue" ) ; } ) ; } ) ; }
This function will remove the given or current job from the database and in-memory array
@param {PersistentQueue} self Instance to work with
@param {integer} [id] Optional job id number to remove, if omitted, remove current job at front of queue
@return {Promise}
This function will remove the given or current job from the database and in - memory array