@adeel2083 wrote:
I am using SQLite with ionic
Ionic:
Ionic CLI : 6.6.0 (C:\Users\ADEEL\AppData\Roaming\npm\node_modules@ionic\cli)
Ionic Framework : @ionic/angular 5.0.5
@angular-devkit/build-angular : 0.900.7
@angular-devkit/schematics : 9.0.7
@angular/cli : 9.0.7
@ionic/angular-toolkit : 2.2.0Cordova:
Cordova CLI : 9.0.0 (cordova-lib@9.0.1)
Cordova Platforms : android 8.1.0, browser 6.0.0
Cordova Plugins : cordova-plugin-ionic-webview 4.1.3, (and 9 other plugins)Utility:
cordova-res (update available: 0.13.0) : 0.6.0
native-run (update available: 1.0.0) : 0.2.8System:
Android SDK Tools : 26.1.1 (C:\Users\ADEEL\AppData\Local\Android\Sdk)
NodeJS : v12.16.1 (C:\Program Files\nodejs\node.exe)
npm : 6.13.4
OS : Windows 10I have a table with 16 records in log_book table and 1 record each in department and location. when i run the query first time it will take almost 15 to 20 seconds but after that it runs in milliseconds. Calling function as follow
getLogBooks(): Promise<LogBook>{
return this.storage.executeSql(SELECT l.id, l.log_book_id, IFNULL(l.machine_no, "") machine_no , d.department_name, loc.location_name, l.section, l.area FROM log_book l INNER JOIN departments d ON l.department_id = d.id INNER JOIN locations loc ON l.location_id = loc.id WHERE l.deleted_at IS NULL
, )
.then(res => {
const items: LogBook = ;
console.log(‘Log BOOK’, res.rows.length)
if (res.rows.length > 0) {
for (let i = 0; i < res.rows.length; i++) {
items.push({
id: res.rows.item(i).id,
LogBookID: res.rows.item(i).log_book_id,
MachineNo: res.rows.item(i).machine_no,
Department: res.rows.item(i).department_name,
Location: res.rows.item(i).location_name,
Section: res.rows.item(i).section,
Area: res.rows.item(i).area
});
}
}
return items;
});
}Table structure
CREATE TABLE IF NOT EXISTS
log_book
(
id
integer primary key autoincrement,
log_book_id
varchar(50) NOT NULL,
machine_no
varchar(50) DEFAULT NULL,
department_id
int(11) NOT NULL,
location_id
int(11) NOT NULL,
section
varchar(50) NOT NULL,
area
varchar(50) NOT NULL,
created_at
timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at
timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
created_by
int(11) DEFAULT NULL,
updated_by
int(11) DEFAULT NULL,
deleted_at
datetime DEFAULT NULL
);CREATE TABLE IF NOT EXISTS
departments
(
id
integer primary key autoincrement,
department_name
varchar(50) NOT NULL,
created_at
timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at
timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
created_by
int(11) DEFAULT NULL,
updated_by
int(11) DEFAULT NULL,
deleted_at
datetime DEFAULT NULL
);CREATE TABLE IF NOT EXISTS
locations
(
id
integer primary key autoincrement,
location_name
varchar(50) NOT NULL,
created_at
timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at
timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
created_by
int(11) DEFAULT NULL,
updated_by
int(11) DEFAULT NULL,
deleted_at
datetime DEFAULT NULL
);What i am doing wrong.
Thanking you in anticipation
Posts: 1
Participants: 1