API Tweaks: Database.view(), Database.save_many()

Bug #1022061 reported by Jason Gerard DeRose
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Microfiber
Fix Released
High
Jason Gerard DeRose

Bug Description

Some misc API changes I grouped up here:

* Database.view() now includes reduce=False by default, which is really how the CouchDB API should work in the first place. For code that only uses a non-reduced view, it sucks for this code to have to know whether there is a reduce function. James and I discussed this a while back, so I'm trying it first in Microfiber, and then will add it to couch.js if we like it.

* Renamed new "non-atomic" Database.bulksave() to Database.save_many() because combined with Database.get_many(), it makes for a clearer, more consistent API.

* Renamed original "all-or-nothing" Database.bulksave2() back to Database.bulksave(). This way there is no API breakage, just in case anyone out there has been using this and wants the "all-or-nothing" behavior, understanding the implications. But I think we should deprecate this method soon. My idea with the convenience methods isn't to capture every scenario, but instead to just capture a few important patterns that might be tricky to get right using post(), get(), etc.

* Adds experimental id_slice_iter() function to give you all the ids from the rows is a view result, but chunked into groups of 25 (override with size=10 or whatever). This is for certain operations in Dmedia where we need to update a large number of docs, like the new Core.purge_store() method. So the idea is as you go through the view results, you use Database.get_many() to get 25 docs, update them all, and then save them back with Database.save_many(). This provides a huge performance improvement over get()/save() for each doc... 10x easily.

Related branches

Changed in microfiber:
status: In Progress → Fix Committed
Changed in microfiber:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.