Pagination in CouchDB?

The CouchDB Guide has a good discussion of pagination, including lots of sample code, here: http://guide.couchdb.org/draft/recipes.html#pagination Here’s their algorithm: Request rows_per_page + 1 rows from the view Display rows_per_page rows, store last row as next_startkey As page information, keep startkey and next_startkey Use the next_* values to create the next link, and use the others … Read more

new FormData() “application/x-www-form-urlencoded”

FormData will always be sent as multipart/form-data. If you just post normal form data without uploading files, multipart/form-data is better. If you want to upload files, multipart/form-data is better. If you have to upload files with x-www-form-urlencoded, you should convert the files data to string data via base64 etc, and write special server-end code. This … Read more

Retrieve just deleted document

Ok, figured it out, if anyone interested: get deleted history, e.g.: curl http://example.iriscouch.com/test/_changes you’ll see deleted documents with $id and $rev, put empty document as new version, e.g.: curl -X PUT http://example.iriscouch.com/test/$id?rev=$rev -H “Content-Type: application/json” -d {} now you can get all revisions info, e.g: curl http://example.iriscouch.com/test/$id?revs_info=true obtain version before deletion, e.g.: curl http://example.iriscouch.com/test/$id?rev=$prev_rev put … Read more

Serialize and Deserialize Objective-C objects into JSON

Finally we can solve this problem easily using JSONModel. This is the best method so far. JSONModel is a library that generically serialize/deserialize your object based on Class. You can even use non-nsobject based for property like int, short and float. It can also cater nested-complex JSON. Considering this JSON example: { “accounting” : [{ … Read more

Can I do transactions and locks in CouchDB?

No. CouchDB uses an “optimistic concurrency” model. In the simplest terms, this just means that you send a document version along with your update, and CouchDB rejects the change if the current document version doesn’t match what you’ve sent. It’s deceptively simple, really. You can reframe many normal transaction based scenarios for CouchDB. You do … Read more

Why should I use document based database instead of relational database?

Probably you shouldn’t 🙂 The second most obvious answer is you should use it if your data isn’t relational. This usually manifests itself in having no easy way to describe your data as a set of columns. A good example is a database where you actually store paper documents, e.g. by scanning office mail. The … Read more

tech