-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathManageTables.js
170 lines (150 loc) · 4.34 KB
/
ManageTables.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
import * as SQLite from 'expo-sqlite';
const globalDB = SQLite.openDatabase('global-8');
export const createUniqueTables = (db) => {
createTokenTable(db);
createSyncTable(db);
createNodesTable(db);
createTaxonomyTable(db);
createAtomTable(db);
createNodesSavedTable(db);
createContentTypesTable(db);
createContentTypeTable(db);
createDisplayModesTable(db);
createSavedOfflineTable(db);
createSiteInfoTable(db);
createListDisplayModes(db);
createViewableTypesTable(db);
createParagraphsTable(db);
createFieldCollectionsTable(db);
};
export const createGlobalTables = async () => {
console.log('create global tables');
return new Promise((resolve, reject) => globalDB.transaction(tx => {
tx.executeSql('create table if not exists user (siteUrl primary key, user text);');
tx.executeSql('create table if not exists database (siteUrl primary key, databaseName text);');
tx.executeSql('create table if not exists savedinfo (url primary key, username text);',
'', (_, result) => resolve, reject);
}));
// globalDB.transaction(tx => {
// tx.executeSql(
// 'create table if not exists database (siteUrl primary key, databaseName text);'
// );
// });
// globalDB.transaction(tx => {
// tx.executeSql(
// 'create table if not exists savedinfo (url primary key, username text);'
// );
// });
}
// Below are functions not being exported
const createTokenTable = (db) => {
db.transaction(tx => {
tx.executeSql(
'create table if not exists auth (id integer primary key, token text, cookie text);'
);
});
}
const createSyncTable = (db) => {
db.transaction(tx => {
tx.executeSql(
'create table if not exists sync (id integer primary key, last integer);'
);
});
}
const createNodesTable = (db) => {
db.transaction(tx => {
tx.executeSql(
'create table if not exists nodes (nid integer primary key, title text, entity text, editable boolean);'
);
});
}
const createTaxonomyTable = (db) => {
db.transaction(tx => {
tx.executeSql(
'create table if not exists taxonomy (tid integer primary key, title text, entity text);'
);
});
}
const createListDisplayModes = (db) => {
db.transaction(tx => {
tx.executeSql(
'create table if not exists list_display_modes (blob);'
);
});
}
const createAtomTable = (db) => {
db.transaction(tx => {
tx.executeSql(
'create table if not exists atom (sid integer primary key, title text, entity text);'
);
});
}
const createNodesSavedTable = (db) => {
db.transaction(tx => {
tx.executeSql(
'create table if not exists nodes_saved (nid integer primary key, title text, entity text);'
);
});
}
const createParagraphsTable = (db) => {
db.transaction(tx => {
tx.executeSql(
'create table if not exists paragraphs (pid integer primary key, blob text);'
);
});
}
const createFieldCollectionsTable = (db) => {
db.transaction(tx => {
tx.executeSql(
'create table if not exists fieldcollections (fid integer primary key, blob text);'
);
});
}
const createContentTypesTable = (db) => {
db.transaction(tx => {
tx.executeSql(
'create table if not exists content_types (id integer primary key, blob text);'
);
});
}
const createContentTypeTable = (db) => {
db.transaction(tx => {
tx.executeSql(
'create table if not exists content_type (machine_name text primary key, blob text);'
);
});
}
const createDisplayModesTable = (db) => {
db.transaction(tx => {
tx.executeSql(
'create table if not exists display_modes (machine_name text primary key, node_view text, list_view text);'
);
});
}
const createSiteInfoTable = (db) => {
db.transaction(tx => {
tx.executeSql(
'create table if not exists site_info (site_name text primary key, mobile_enabled boolean, logo text);'
);
});
}
const createViewableTypesTable = (db) => {
db.transaction(tx => {
tx.executeSql(
'create table if not exists viewable_types (machine_name text primary key, blob text);'
);
});
}
const createSavedOfflineTable = (db) => {
/* console.log(db);
db.transaction(tx => {
tx.executeSql(
'drop table if exists saved_offline;'
);
});*/
db.transaction(tx => {
tx.executeSql(
'create table if not exists saved_offline (id integer primary key, blob text, saved boolean, error text);'
);
});
}