-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathidb_service.js
59 lines (50 loc) · 1.41 KB
/
idb_service.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
import { DATA_TYPE, Connection } from 'jsstore';
/* eslint import/no-webpack-loader-syntax: off */
;
const getWorkerPath = () => {
if (process.env.NODE_ENV === 'development') {
return require("file-loader?name=scripts/[name].[hash].js!jsstore/dist/jsstore.worker.js");
}
else {
return require("file-loader?name=scripts/[name].[hash].js!jsstore/dist/jsstore.worker.min.js");
}
};
const workerPath = getWorkerPath().default;
export const idbCon = new Connection(new Worker(workerPath));
export const dbname = 'instances';
export const getDatabase = () => {
const tblInstance = {
name: 'Instances',
columns: {
id: {
primaryKey: true,
autoIncrement: true
},
name: {
notNull: true,
dataType: DATA_TYPE.String
},
color: {
dataType: DATA_TYPE.String,
default: null
},
ram: {
notNull: true,
dataType: DATA_TYPE.Number
},
cpu: {
notNull: false,
dataType: DATA_TYPE.Number
},
pricing: {
notNull: true,
dataType: DATA_TYPE.Object
},
}
};
const dataBase = {
name: dbname,
tables: [tblInstance]
};
return dataBase;
};