
A SQLite Tutorial with Node.js - ScottWRobinson
http://stackabuse.com/a-sqlite-tutorial-with-node-js/
======
le-mark
I didn't see anything in the code to address database contention for
inserts/updates. This is SQLites achilles heel, even in a single process, with
multiple writing threads. But it's _easily_ remedied by "serializing" writes
with a queue or lock for example. Many claim WAL remedies this, but in my
test, WAL still succumbs to contention. Time out and retry is another possible
solution.

The other thing is setting the sync and journaling mode on the connection. You
have to do that for every connection, if you do want to use WAL mode.

SQLite can be quite high performance if done right.

~~~
guntars
You're not likely to run multiple threads in NodeJS. If you do need to scale
up to multiple threads or processes, SQLite might not be the right choice, but
then again it was never designed for that use case.

~~~
Scarbutt
_You 're not likely to run multiple threads in NodeJS._

Nodejs itself won't but libuv will.

------
davide_ross
Why use bluebird promises instead of native ones? Are them faster or is it
just old habits?

~~~
koolba
Bluebird's promise implementation is faster in the common case (single
thenable chain) and also includes some non-standard convenience functions for
composing groups of Promises.

The performance differences are meaningless for _most_ people but if you're
used to coding with the convenience functions it's annoying to not have them
available.

~~~
invalid_
I couldn't find a single use that had bluebird only functionality.

------
pmlamotte
I came across a use case for sqlite recently for storing some data I was
scraping, and went through hell with the sqlite3 package due to the seemingly
unnecessary async calls for everything. I've heard better-sqlite3[1] solves a
lot of the problems since it is synchronous, and ends up having better
performance as a result.

That said, the sqlite3 package soured me on it so much I ended up rewriting my
script in clojure instead which came with the benefits of being able to use
other jdbc libraries like honeysql.

[1] [https://github.com/JoshuaWise/better-
sqlite3](https://github.com/JoshuaWise/better-sqlite3)

~~~
gkya
While asynchronous programming seems to be simpler than some other concurrency
models, it still is way complicated when compared to normal sequential
programming; and thus should be opt-in, not inevitable by default. Some time
ago I wanted to have a little firefox addon that would list bookmarks tagged
unread, and IIRC I had to use promises and async calls, all in some ten lines
program that essentially maps a function recursively over a tree (which I
didn't have to do explicitly because that was what the promise API did for
me).

------
kizer
I think that the DAO should abstract more away. It shouldn't simply allow SQL
input - that defeats the purpose.

