
PouchDB, the In-Browser Database That Replicates - mbroberg
https://cloudant.com/blog/pouchdb/
======
daleharvey
Nice to see some good discussion about PouchDB, cheers for all the thanks as
well but just wanted to make sure the credit goes where its due, PouchDB is a
fairly small project that I do in my (rare) spare time, but it has 55
contributors who very much make it the project it is

[https://github.com/daleharvey/pouchdb/graphs/contributors](https://github.com/daleharvey/pouchdb/graphs/contributors)

------
undoware
I'm surprised more people haven't heard of PouchDB, so good on Cloudant for
donating buzz to an excellent FOSS project. And thanks again, Dale Harvey, for
being a fscking genius. :)

My boss tells me I'll be making a whole private document management & CRM
around it and CouchDB, and that's my fault for showing them to him.

~~~
teleclimber
I'm just getting interested in CouchDB and PouchDB. I almost jumped out of my
chair when I found PouchDB earlier this week. So brilliant!

Will you be sharing your development experiences somewhere? It seems there is
less info out there compared to, say, Mongo.

~~~
undoware
As much as possible, yes -- my employer has only recently gotten into
sponsoring FOSS, so I have to do a lot of comforting around the, "but what if
someone else takes this and copies us" question. Which is fair: They (still)
don't teach FOSS community balancing in MBA school. In fact, I just made the
term 'community balancing' up, but only because we both know there should be
one, and isn't.

------
DenisM
Apparently Cloudant is a couch-compatible cloud-scale database. It would be
nice if they mentioned this somewhere on their site, especially after having
named their product PouchDB.

A question that remains unanswered for me is how do they go about storing the
local data in the browser? Do they use local storage? Are there size limits?
What's reliability like?

~~~
teleclimber
As far as I know, cloudant's product is BigCouch which was a fork of CouchDB
but has recently been merged back in:

[https://blogs.apache.org/couchdb/entry/welcome_bigcouch](https://blogs.apache.org/couchdb/entry/welcome_bigcouch)

~~~
garbados
Cloudant is a hosted, managed, distributed database as a service. We're based
on CouchDB, but then added clustering, then full-text search, and -- coming
soon -- geo-indexing :D

BigCouch, and the clustering abilities that we're merging back into CouchDB,
are open-source artifacts of the work we do on the core product. The open-
source community gave us so much, and we love giving back :D

~~~
teleclimber
Ah, thanks for clarifying!

And I think it's great that BigCouch is being merged back into CouchDB. I'm
just getting interested in CouchDB and PouchDB and it seems these projects
deserve the love.

------
ryderm
How does this handle security? Sending data directly into a database from the
browser with no application layer sounds a bit scary.

~~~
stevekemp
If you look at their demo code it has a username and password right in the
javascript source - as you would expect - which means keen users could do all
kinds of things.

~~~
garbados
Aye, which is why putting your administrative credentials in client-side
JavaScript is an unspeakably bad idea.

Instead, serve {client,user}-specific keys from the server on request, or let
the user generate them through a signin process in the frontend, say by using
the _users database that CouchDB and Cloudant allow.

~~~
undoware
Yes. But it _is_ demo code, meaning that the use case isn't production, it's
education. And the UX of education is a lot worse when you have to begin by
saying, "this will look different from yours" and "here's a whole extra layer
of complication I'm going to introduce, but don't worry it's a best practice."

~~~
daleharvey
Exactly, the username / password combination is most certainly to make life
simpler for a demo, would never expect someone to do that in real code.

I plan on extending the getting started tutorial with an extention that does a
database oer user when logged in (via persona), it actually wont make the
tutorial much more complex and gets very close to what it should look like in
production ([https://github.com/daleharvey/couch-
persona](https://github.com/daleharvey/couch-persona))

------
borbulon
According to the FAQ in FF it's using IndexedDB, what's it using in
Chrome/Opera/IE? LocalStorage?

Also, what do you do about FF's seeming need to pluralize all store names,
default out-of-order keys, and clear cache issue?

edit for clarity

~~~
teraflop
Your first question is answered here, under "Browser Support":
[http://pouchdb.com/learn.html](http://pouchdb.com/learn.html)

------
jchrisa
PouchDB will also sync with Couchbase Sync Gateway. We use PouchDB as part of
the load-generator cluster for performance testing.
[http://www.couchbase.com/communities/couchbase-sync-
gateway](http://www.couchbase.com/communities/couchbase-sync-gateway)

There are more and more things that can sync this awesome JSON HTTP protocol.
[http://syncable.org/](http://syncable.org/)

Thanks Dale!

~~~
mlmilleratmit
And jchris jumps in with the couchbase marketing, love it. You're right,
though, about how rad it is that so many things speak the Apache CouchDB
replication protocol. I'm eager to hear Max talk more about syncable because I
thought that may be a more minimal protocol for sync than the full Couch
dance.

------
marcus_holmes
I was immediately struck by the scary thing of putting the password in the
URL:

    
    
        remote = 'https://USERNAME:PASSWORD@USERNAME.cloudant.com/DATABASE'
    

I know HTTPS URLs are encrypted, but it still strikes me as unsafe. What does
HN think?

~~~
fiatjaf
This is demo code. See this comment:
[https://news.ycombinator.com/item?id=6612482](https://news.ycombinator.com/item?id=6612482)

But it can work with cookie authentication with just a little more lines of
code.

------
qwerta
Does it store data serialized or in object form? I am not sure how JS reacts
to a few millions objects.

~~~
daleharvey
It stored plain objects, they are persisted to disk so memory shouldnt really
be a concern, it uses idb in firefox / chrome, websql in others (or leveldb in
node)

------
plnodiplnodi
I use pouchdb with pouchappy.com. Excellent combination.

------
elchief
Does it have any offline-storage capabilities?

~~~
garbados
Yep! It replicates your remote database to a local store (IndexedDB on the
browser, LevelDB in Node.js), so that losing connection doesn't stop your app.
When you regain connection, it continues replicating as normal.

~~~
elchief
Sweet.

