{{ !articles[0].partner.isSponsoringArticle ? "Platinum" : "Portal" }} Partner

CouchDB: 'Badmatch' When Executing View

I’ve been playing around with CouchDB again in my annual attempt to capture the links appearing on my twitter stream and I managed to create the following error for myself:

$ curl
{"error":"badmatch","reason":"{\n   \"find_broken_links\": {\n       \"map\": \"function(doc) {   \nvar prefix = doc.actual_link.match(/.*/);      

It turns out this error is because I’ve managed to create new line characters in the view while editing it inside CouchDBX. D’oh!

A better way is to edit the view in a text editor and then send it to CouchDB using curl.

The proper way to update a view would be to add a ‘_rev’ property to the body of the JSON document but I find it annoying to go and edit the document so I’ve just been deleting and then recreating my views.

$ curl -X GET
$ curl -X DELETE
$ curl -X PUT -d @cleanup.json

I guess there’s probably a library somewhere which would encapsulate all that for me but I’m just hacking around at the moment.

It’s interesting to to see how you interact differently with a document database compared to what you’d do with a relational one with respect to optimistic concurrency.

Published at DZone with permission of {{ articles[0].authors[0].realName }}, DZone MVB. (source)

Opinions expressed by DZone contributors are their own.

{{ tag }}, {{tag}},

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}
{{ parent.authors[0].realName || parent.author}}

{{ parent.authors[0].tagline || parent.tagline }}

{{ parent.views }} ViewsClicks