· 8 years ago · Jul 15, 2018, 05:44 AM
1var membersDatabaseHandler = {
2 db: null,
3 createDatabase: function(){
4 this.db = window.openDatabase(
5 "members.db",
6 "1.0",
7 "members database",
8 1000000);
9 this.db.transaction(
10 function(tx){
11 //Run sql here using tx
12 tx.executeSql(
13 "create table if not exists member(_id integer primary key, firstName text, lastName text, phone number)",
14 [],
15 function(tx, results){},
16 function(tx, error){
17 console.log("Error while creating the member table: " + error.message);
18 }
19 );
20 },
21 function(error){
22 console.log("Members DB Transaction error: " + error.message);
23 },
24 function(){
25 console.log("Create Members DB transaction completed successfully");
26 }
27 );
28 }
29}
30
31 var productsDatabaseHandler = {
32 db: null,
33 createDatabase: function(){
34 this.db = window.openDatabase(
35 "products.db",
36 "1.0",
37 "products database",
38 1000000);
39 this.db.transaction(
40 function(tx){
41 //Run sql here using tx
42 tx.executeSql(
43 "create table if not exists product(_id integer primary key, name text, price number, image text)",
44 [],
45 function(tx, results){},
46 function(tx, error){
47 console.log("Error while creating the product table: " + error.message);
48 }
49 );
50 },
51 function(error){
52 console.log("Products DB Transaction error: " + error.message);
53 },
54 function(){
55 console.log("Create Products DB transaction completed successfully");
56 }
57 );
58 }
59}
60
61var ordersDatabaseHandler = {
62 db: null,
63 createDatabase: function(){
64 this.db = window.openDatabase(
65 "orders.db",
66 "1.0",
67 "orders database",
68 1000000);
69 this.db.transaction(
70 function(tx){
71 //Run sql here using tx
72 tx.executeSql(
73 "create table if not exists order(_id integer primary key, memberID number, name text, price number, items text)",
74 [],
75 function(tx, results){},
76 function(tx, error){
77 console.log("Error while creating the order table: " + error.message);
78 }
79 );
80 },
81 function(error){
82 console.log("Orders DB Transaction error: " + error.message);
83 },
84 function(){
85 console.log("Create Orders DB transaction completed successfully");
86 }
87 );
88 }
89}