CouchDB looks cool, but the documentation is horrible (at least for starting out using Javascript).
Something I didn't fully appreciate is that you can't call out to different a server from Javascript directly (this is "cross-site scripting", and there are workarounds). Essentially, it's assumed any connections will be performed on the server side and the client (browser) connects to a single server. The quick-and-dirty solution is to host the Player's Companion from my local CouchDB instance:
- Log in to Futon: http://localhost:5984/_utils/index.html
- Create a database (charmgr) to host the files
- Create a document (id: "charmgr")
- Upload all the files as attachments to the document
- Go to: http://localhost:5984/charmgr/charmgr/charmgr.html, et voila!
In the code, writing out the data is direct:
var db = new CouchDB(cookie_name.toLowerCase(), {"X-Couch-Full-Commit":"false"});
db.createDb();
db.save(data);
Thanks to Justin Walgran: http://mail-archives.apache.org/mod_mbox/couchdb-user/200812.mbox/%3Cf893e2810812262119k3163421ds372d4b7a2eac22c1@mail.gmail.com%3E
Useful: http://sitr.us/2009/06/30/database-queries-the-couchdb-way.html
No comments:
Post a Comment