function find(q){

	  		var deffered = $q.defer();
	  		dbService.connect().then(function(){
	  			//var search = new RegExp("^"+q+".*$", 'i');
	  			var search = new RegExp(""+q+"", 'i');

	  			//console.log(search);
		  		dbService.db_.select()
		  				.from(dbService.productTable)
		  				.where(dbService.productTable.name.match(search))
		  				.exec()
		  				.then(function(r){
		  					deffered.resolve(r);
		  				});
	  		})
	  		return deffered.promise;
	  	}
/* 
	  	* This will perform query on product table 
	  	* and returns all products with name starting
	  	* with q
	  	*/
This will perform query on product table
and returns all products with name starting
with q
This will perform query on product table and returns all products with name starting with q
function find(q){
	  		var deffered = $q.defer();
	  		dbService.connect().then(function(){
	  			var search = new RegExp(""+q+"", 'i');
		  		dbService.db_.select()
		  				.from(dbService.productTable)
		  				.where(dbService.productTable.name.match(search))
		  				.exec()
		  				.then(function(r){
		  					deffered.resolve(r);
		  				});
	  		})
	  		return deffered.promise;
	  	}
function find ( q ) { var deffered = $q . defer ( ) ; dbService . connect ( ) . then ( function ( ) { var search = new RegExp ( "" + q + "" , 'i' ) ; dbService . db_ . select ( ) . from ( dbService . productTable ) . where ( dbService . productTable . name . match ( search ) ) . exec ( ) . then ( function ( r ) { deffered . resolve ( r ) ; } ) ; } ) return deffered . promise ; }
This will perform query on product table
 and returns all products with name starting
 with q
This will perform query on product table and returns all products with name starting with q
//var search = new RegExp("^"+q+".*$", 'i'); //console.log(search);