Comments (7)
you're right, both .close()
and .create_function(name, func)
are not exposed/available, but I guess these should.
from sqlite-worker.
+1
I need the classic db.prepare
because I usually create function like this:
function insertNote(toInsert) {
const keys = Object.keys(toInsert)
// Doing this because some columns are optional
const info = db.prepare(`INSERT INTO note
(${keys.join(',')})
VALUES
(${keys.map(k => '@' + k).join(',')})
`).run(toInsert)
...
}
I cannot make it work with sqlite-tag
. Are there any workaround?
from sqlite-worker.
@onlyfortesting what has prepare to do with exposure of close and create function? that + the fact you don't need to prepare anything with sqlite-tag, that's the whole idea, but transaction with commit eventually works.
from sqlite-worker.
@twoxfh both close
and create_function
are in. Bear in mind when used through the Worker create_function
can accept only pure functions without any outer scope access, because functions don't survive the post message dance. This limitation does not exist when used directly through the initializator.
from sqlite-worker.
Great..I tested as well. Not sure if it needs mentioning, if an error is thrown in a custom function the current and all queries after, stop.. You can use it to count running time on queries and throw errors for long running queries. Of course if it's a long running row evaluation it does not help. Emscripten is working on WASMFS which will use pthreads and the you can kill the thread for row evaluation issues.
from sqlite-worker.
if an error is thrown in a custom function the current and all queries after, stop
uhm ... I should likely wrap that in a try/catch then .. would that fix the issue?
from sqlite-worker.
@WebReflection Yep. It has nothing to do with those methods. But, since OP also asked if there is a way to interact directly with the sqlitedb instance (which I also wanted to do) so I thought I'd rather comment on this issue as well than creating a new one.
Anyway, I have found solution to my problem. Basically, I'm trying to do this query with sqlite-tag
const keys = Object.keys(toInsert)
db.query`
INSERT INTO notes (${db.raw`${keys.join(',')}`})
VALUES (${keys.map(c => toInsert[c]).joins(db.raw`,`)}) -- this part throws`
Which doesn't work. So, I originally thought it can't be done without exposing .prepare
. Turns out I just don't completely understand how tagged template works .joins(db.raw`,`)
part.
Thanks for such a great lib, btw
from sqlite-worker.
Related Issues (10)
- Failed to execute 'transaction' on 'IDBDatabase'
- Absurd-Sql HOT 3
- Any examples using TypeORM? HOT 1
- Access to DB instance from the worker? HOT 6
- Resolve both `dir` and `library` options by default.
- Errors in both Firefox and Chrome on MacOS HOT 4
- Testing Plugin HOT 8
- Problem injecting into query HOT 26
- OOM HOT 31
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sqlite-worker.