function seed(){
	  		var defered = $q.defer();
	  		//fetch data from server
	  		fetchData().then(function(response){
	  			if(!response.IsValid){
	  				defered.reject();
	  				//console.log('something went wrong while fetching products from server.')
	  				return;
	  			}
	  			
	  			//connect to database before any action
		  		dbService.connect().then(function(){
		  			//delete older data before inserting new
		  			dbService.deleteAll([dbService.productTable, dbService.productVariantTable,dbService.orderTable, dbService.orderItemsTable])
		  				.then(function(){

		  					//insert data into db
			  				insertSeedData(response.Payload)
			  					.then(function(){
			  						//seed completed successfully
			  						// console.log('Refreshed');
			  						defered.resolve()
			  					}).catch(function(){
			  						//console.log('coulnt insert product data into local db');
			  						defered.reject();
			  					});

		  				}).catch(function(){
		  					//console.log('coulnt delete products from db');
		  					defered.reject();
		  				})

		  		}).catch(function(){
		  			//console.log('coulnt connect to db');
		  			defered.reject();
		  		})

	  		}).catch(function(){
	  			//console.log('something went wrong while fetching products from server.');
	  			defered.reject();
	  		})

	  		return defered.promise;
	  	}
/*Seed product and product variant table
	  	* from server
	  	*/
Seed product and product variant table
from server
Seed product and product variant table from server
function seed(){
	  		var defered = $q.defer();
	  		fetchData().then(function(response){
	  			if(!response.IsValid){
	  				defered.reject();
	  				return;
	  			}
		  		dbService.connect().then(function(){
		  			dbService.deleteAll([dbService.productTable, dbService.productVariantTable,dbService.orderTable, dbService.orderItemsTable])
		  				.then(function(){
			  				insertSeedData(response.Payload)
			  					.then(function(){
			  						defered.resolve()
			  					}).catch(function(){
			  						defered.reject();
			  					});
		  				}).catch(function(){
		  					defered.reject();
		  				})
		  		}).catch(function(){
		  			defered.reject();
		  		})
	  		}).catch(function(){
	  			;
	  			defered.reject();
	  		})
	  		return defered.promise;
	  	}
function seed ( ) { var defered = $q . defer ( ) ; fetchData ( ) . then ( function ( response ) { if ( ! response . IsValid ) { defered . reject ( ) ; return ; } dbService . connect ( ) . then ( function ( ) { dbService . deleteAll ( [ dbService . productTable , dbService . productVariantTable , dbService . orderTable , dbService . orderItemsTable ] ) . then ( function ( ) { insertSeedData ( response . Payload ) . then ( function ( ) { defered . resolve ( ) } ) . catch ( function ( ) { defered . reject ( ) ; } ) ; } ) . catch ( function ( ) { defered . reject ( ) ; } ) } ) . catch ( function ( ) { defered . reject ( ) ; } ) } ) . catch ( function ( ) { defered . reject ( ) ; } ) return defered . promise ; }
Seed product and product variant table
 from server
Seed product and product variant table from server
//fetch data from server //console.log('something went wrong while fetching products from server.') //connect to database before any action //delete older data before inserting new //insert data into db //seed completed successfully // console.log('Refreshed'); //console.log('coulnt insert product data into local db'); //console.log('coulnt delete products from db'); //console.log('coulnt connect to db'); //console.log('something went wrong while fetching products from server.');