goby-database 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +26 -10
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -19,6 +19,17 @@ class Project{
|
|
|
19
19
|
console.log('opened goby database');
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
+
this.db.function('junction_obj', (side_a, side_b) => {
|
|
23
|
+
|
|
24
|
+
let split_1=side_a.split('.');
|
|
25
|
+
let split_2=side_b.split('.');
|
|
26
|
+
let c1=`"class_id":${split_1[0]}`;
|
|
27
|
+
let p1=split_1[1]?`,"prop_id":${split_1[1]}`:'';
|
|
28
|
+
let c2=`"class_id":${split_2[0]}`;
|
|
29
|
+
let p2=split_2[1]?`,"prop_id":${split_2[1]}`:'';
|
|
30
|
+
return `[ {${c1}${p1}}, {${c2}${p2}} ]`;
|
|
31
|
+
});
|
|
32
|
+
|
|
22
33
|
//prepared statements with arguments so my code isn't as verbose elsewhere
|
|
23
34
|
this.run={
|
|
24
35
|
begin:this.db.prepare('BEGIN IMMEDIATE'),
|
|
@@ -64,23 +75,28 @@ class Project{
|
|
|
64
75
|
//System table to contain generated image data
|
|
65
76
|
this.create_table('system','images',['file_path TEXT','img_type TEXT','img BLOB']);
|
|
66
77
|
|
|
78
|
+
this.create_table('system','windows',[
|
|
79
|
+
'id INTEGER NOT NULL PRIMARY KEY',
|
|
80
|
+
'type TEXT',
|
|
81
|
+
'open INT',
|
|
82
|
+
'metadata TEXT'
|
|
83
|
+
]);
|
|
84
|
+
|
|
85
|
+
this.db.prepare(`INSERT INTO system_windows
|
|
86
|
+
(type, open, metadata)
|
|
87
|
+
VALUES
|
|
88
|
+
('home',0,'${JSON.stringify({pos:[null,null], size:[540,400]})}'),
|
|
89
|
+
('hopper',0,'${JSON.stringify({pos:[null,null], size:[300,400]})}')`).run();
|
|
90
|
+
|
|
67
91
|
// [TO ADD: special junction table for root objects to reference themselves in individual relation]
|
|
68
92
|
this.create_table('system','junction_root',[
|
|
69
93
|
'id_1 INTEGER',
|
|
70
94
|
'id_2 INTEGER',
|
|
71
95
|
'metadata TEXT'
|
|
72
96
|
]);
|
|
97
|
+
|
|
73
98
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
let split_1=side_a.split('.');
|
|
77
|
-
let split_2=side_b.split('.');
|
|
78
|
-
let c1=`"class_id":${split_1[0]}`;
|
|
79
|
-
let p1=split_1[1]?`,"prop_id":${split_1[1]}`:'';
|
|
80
|
-
let c2=`"class_id":${split_2[0]}`;
|
|
81
|
-
let p2=split_2[1]?`,"prop_id":${split_2[1]}`:'';
|
|
82
|
-
return `[ {${c1}${p1}}, {${c2}${p2}} ]`;
|
|
83
|
-
});
|
|
99
|
+
|
|
84
100
|
|
|
85
101
|
|
|
86
102
|
}
|