AlaSQL / alasql

AlaSQL.js - JavaScript SQL database for browser and Node.js. Handles both traditional relational tables and nested JSON data (NoSQL). Export, store, and import data from localStorage, IndexedDB, or Excel.
http://alasql.org
MIT License
7.01k stars 651 forks source link

Asynch fail of create FILESTORAGE #980

Open peterprib opened 6 years ago

peterprib commented 6 years ago

alasql('CREATE FILESTORAGE DATABASE system("./systemDB.json")')

This fails async some time later causing total script failure and not possible to try/catch

Error: Cannot create new database file, because it alreagy exists at C:\Users\db2admin\git\nodaldbms\node_modules\alasql\dist\alasql.fs.js:19159:11 at FSReqWrap.cb [as oncomplete] (fs.js:257:19)

mathiasrw commented 6 years ago

Hi Peter. Its awesome that you find all these problems and make issues about them.

Fixed the spelling error at first!

All interaction with the filesystem in async. No try catch would work. Have you tried catch with a promise notation?

alasql(['CREATE FILESTORAGE DATABASE system("./systemDB.json")'])
.then(res=≥{console.log(res)})
.catch(e=>{console.log('something went wrong', e)})

I cant test run this myself at this moment, so sorry if this is not working.

peterprib commented 6 years ago

yes

my the was alasql.exec(['create ...']) does not work as it doesn't accept an array. Promise works

Regards

Peter Prib

On 25 February 2018 at 21:18, Mathias Rangel Wulff <notifications@github.com

wrote:

Hi Peter. Its awesome that you find all these problems and make issues about them.

Fixed the spelling error at first!

All interaction with the filesystem in async. No try catch would work. Have you tried catch with a promise notation?

alasql(['CREATE FILESTORAGE DATABASE system("./systemDB.json")']) .then(res=≥{console.log(res)}) .catch(e=>{console.log('something went wrong', e)})

I cant test run this myself at this moment, so sorry if this is not working.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/agershun/alasql/issues/980#issuecomment-368298050, or mute the thread https://github.com/notifications/unsubscribe-auth/AHPERO9qxBhrq179TGjh39MbIgSY96Trks5tYTNogaJpZM4SSPCJ .

mathiasrw commented 6 years ago

No, alasql.exec will for sure not work as it does not support the shorthand promise notation.

Try alasql(['create ...

renjiza commented 6 years ago

when i run this code

alasql(['CREATE FILESTORAGE DATABASE system("./systemDB.json")']) .then(res=≥{console.log(res)}) .catch(e=>{console.log('something went wrong', e)})

i've got some problem like

something went wrong Error: You can use exists() only in Node.js or Apach Cordova at Object.C.fileExists (alasql.js:11) at Function.pe.createDatabase (alasql.js:16) at K.CreateDatabase.execute (alasql.js:14) at Function.A.dexec (alasql.js:11) at Function.A.exec (alasql.js:11) at A (alasql.js:2) at alasql.js:11 at new Promise () at j (alasql.js:11) at H (alasql.js:11)

is fileStorage engine doesnt support for web browser like chrome ?

renjiza commented 6 years ago

because i got problem using alasql pure DB , when i refresh on my browser and i check my alasql DB is gone , anyone can help me ?

mathiasrw commented 6 years ago

Hi @renjiza - please see the comment I gave you in the other issue.

And please: for the future create a new issue when your question is not directly related to the existing subject.