RELAX, leave backbone alone

I have been playing with backbonejs and CouchDB in my (limited) spare time to see how usable they are together.

Well I have a backbone collection and figured I would fetch a couch view into the collection. Now backbone expects an JSON array and couch gives you a single JSON object that has total and a rows etc.

Image

Hmm…

I started to look around for someone on git that may have done this, not much luck. There were a couple of customisations that have been written but there were a few issues with using the latest backbone release.

I figured I’d start writing my own backbone extension that overrides the sync and fetch functions. I had already done a simple OData JSONP extension for work so I got started.

Then something in the back of my mind said ….list….

I realised you didn’t need to modify backbone, I could use a list function in couch. I even found someone on stackoverflow that had already written one (WIN)

ImageThe more I think about it couch is designed to do things like this, it will add in etags to help cache the list and I can even modify the list to handle different content types.

Hope this helps in some way.

Advertisements