@@ -149,7 +149,7 @@ class MainApp {
149
149
locateFile : ( ) => '../../../node_modules/sql.js/dist/sql-wasm.wasm' ,
150
150
} ) ;
151
151
152
- const dataPromise = fetch ( '../../../ test.sqlite ' ) . then ( res => res . arrayBuffer ( ) ) ;
152
+ const dataPromise = fetch ( '../sqlite/ test-sql.js.db ' ) . then ( res => res . arrayBuffer ( ) ) ;
153
153
const [ SQL , buf ] = await Promise . all ( [ sqlPromise , dataPromise ] ) ;
154
154
const db = new SQL . Database ( new Uint8Array ( buf ) ) ;
155
155
@@ -165,6 +165,35 @@ class MainApp {
165
165
}
166
166
const endTime = Date . now ( ) ;
167
167
this . log ( type , `end time: ${ endTime } , use ${ ( ( endTime - startTime ) / 1000 ) . toFixed ( 2 ) } s` ) ;
168
+ this . _dump ( db ) ;
169
+ }
170
+
171
+ _dump ( db ) {
172
+ // core dump as file
173
+ const binaryArray = db . export ( ) ;
174
+ // download this binaryArray as a file
175
+ const blob = new Blob ( [ binaryArray ] , { type : 'application/octet-stream' } ) ;
176
+ const url = URL . createObjectURL ( blob ) ;
177
+ const a = document . createElement ( 'a' ) ;
178
+ a . download = 'test-sql.js.db' ;
179
+ a . href = url ;
180
+ a . click ( ) ;
181
+
182
+ // const [fileHandle] = await window.showOpenFilePicker({
183
+ // types: [
184
+ // {
185
+ // description: 'sql.js dump file',
186
+ // accept: {
187
+ // 'text/plain': ['.db'],
188
+ // },
189
+ // },
190
+ // ],
191
+ // });
192
+ // const writable = await fileHandle.createWritable();
193
+ // // Write the contents of the file to the stream.
194
+ // await writable.write(binaryArray);
195
+ // // Close the file and write the contents to disk.
196
+ // await writable.close();
168
197
}
169
198
170
199
async runSQLiteWASMInWorker ( type ) {
@@ -215,7 +244,7 @@ class MainApp {
215
244
216
245
worker . onerror = e => console . log ( 'Worker error: ' , e ) ;
217
246
218
- const buf = await fetch ( '../../../ test.sqlite ' )
247
+ const buf = await fetch ( '../sqlite/ test-sql.js-worker.db ' )
219
248
. then ( res => res . arrayBuffer ( ) ) ;
220
249
221
250
worker . postMessage ( {
0 commit comments