nosql tips'n'tricks: All content tagged as nosql tips'n'tricks in NoSQL databases and polyglot persistence
Tuesday, 23 February 2010
CouchDB List Functions
Just another trick for your CouchDB toolbox:
List functions are a mechanism for iterating over rows in a view to produce output. CouchDB list functions are typically used to generate alternate formats for output (Atom, XML, HTML, etc.). I still want to generate JSON for consumption by my Sinatra application. Hopefully, that will not prove difficult.
Other CouchDB tips&tricks
- Paginating with CouchDB
- Access CouchDB document revisions with RelaxDB
- Generic CouchDB _changes consumer using node.js
- A Stub Ruby Library for CouchDB
via: http://japhr.blogspot.com/2010/02/collating-not-reducing-with-couchdb.html
Friday, 19 February 2010
Generic CouchDB _changes consumer using node.js
An interesting tool for those needing a way to process the CouchDB _changes server-side:
However, one thing that’s missing is being able to write some code in your design document that consumes these changes on the backend and doesn’t depend on another active client. To remedy this situation I decided to write a generic change consumer that you could point at CouchDB and it would find any change handlers in any of the design documents and keep them running, consuming changes, and removing or replacing them when the design document changed.
In the past we’ve also seen how to use RabbitMQ to push notifications from _changes, but both these solutions may prove quite useful.
Other CouchDB tips&tricks
Monday, 15 February 2010
A Stub Ruby Library for CouchDB
Continuing our series of CouchDB tips & tricks, I wanted to include RockingChair, a stub[1] Ruby library for CouchDB that would help you out with the speed of the test suite.
Update: Make sure you are reading also Mathias Meyer’s comment below.
Other CouchDB tips & tricks
- Paginating with CouchDB
- Access CouchDB document revisions with RelaxDB
- CouchDB List Functions
- Generic CouchDB _changes consumer using node.js
References
- [1] See these posts about Mocks vs Stubs: ☞ James Kovacs and ☞ Martin Fowler. (↩)
Thursday, 11 February 2010
Access CouchDB document revisions with RelaxDB
A nice trick to get quick access to the CouchDB document revisions with the Ruby RelaxDB library:
I messed with RelaxDB for Ruby for a little while to get this whole revisiony thing to work. For those familiar with RelaxDB, it exposes RelaxDB.load(_id, :revs=>true) for you, but due to limitations in Couch, you can’t get the :revs from a view, only directly loading an object. So to get around this, I mixed a revisions method into the Document class:
Check the other CouchDB tricks
- Paginating with CouchDB
- Generic CouchDB _changes consumer using node.js
- A Stub Ruby Library for CouchDB
- CouchDB List Functions
via: http://fapper.com/post/379058417/easy-document-revisions-with-relaxdb
Paginating with CouchDB
Except the case you are planning to offer your users a very bad experience, you’ll have to figure out a way to paginate through long collections. Using CouchDB is no different from any other storage, maybe it adds a bit of complexity:
CouchDB is a different beast, its aggressive use of indexes means that occasionally you loose some functionality that you’ve been accustomed to having in other persistence mechanisms, like the number of rows matching a query.
The following articles should get you up to speed on how to accomplish pagination while using CouchDB:
- ☞ CouchDB: The last mile (see “Paginate records in CouchDB” section)
- ☞ Jan Lehnardt explanation of the above quoted issue
- ☞ Paginating document with couchrest and will_paginate
And if you have a different solution, please share it with MyNoSQL readers!