Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- async getTotal(){
- for(let records of this.records){
- await this.selectPresentWeekData(records.weekid,records.croppingid); // asynchronous functions contains query in database
- this.loopThroughValues(); // must get the value from the query
- this.loopObjectAccess(); // calculates the total using the values from the query
- this.pushDataToShow(records.weekid); // push the query data to a new object
- }
- }
- selectPresentWeekData(weekid,cropid){
- console.log('Collecting input data'+weekid+' cropid '+cropid);
- this.sqlite.create({name: 'ionicdb.db',location: 'default'}).then((db: SQLiteObject) => {
- const asyncQuery = [
- 'SELECT * FROM input_expenses WHERE input_expenses.week_input_rowid = "'+weekid+'" AND input_expenses.input_crop_rowid = "'+cropid+'"',
- 'SELECT * FROM labor_expenses WHERE labor_expenses.week_labor_rowid = "'+weekid+'" AND labor_expenses.labor_crop_rowid = "'+cropid+'"',
- 'SELECT * FROM food_expenses WHERE food_expenses.week_food_rowid = "'+weekid+'" AND food_expenses.food_crop_rowid = "'+cropid+'"'
- ];
- Promise.all(asyncQuery.map(asyncQuery =>{
- db.executeSql(asyncQuery,{})
- })).then(res => {
- console.log(res);
- }).catch(() => console.log('error'));
- }).catch(e => console.log(e.message));
- }
Add Comment
Please, Sign In to add comment