couchdb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ryan Ramage (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (COUCHDB-1612) Transform all documents at once
Date Mon, 26 Nov 2012 15:37:02 GMT

    [ https://issues.apache.org/jira/browse/COUCHDB-1612?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13503841#comment-13503841
] 

Ryan Ramage commented on COUCHDB-1612:
--------------------------------------

As a workaround, you might want to look at Costco

http://harthur.github.com/costco/

It is an easy way to bulk edit docs.
                
> Transform all documents at once
> -------------------------------
>
>                 Key: COUCHDB-1612
>                 URL: https://issues.apache.org/jira/browse/COUCHDB-1612
>             Project: CouchDB
>          Issue Type: Wish
>          Components: Futon
>            Reporter: jean honlet
>            Priority: Minor
>
> Sometimes, I would like to modify all documents at once...
> I use this function (jQuery, jquery.couchdb and Underscore necessary):
> function actionAllTransform(transform, commit) {
>     // First get all documents:
>     jQuery.couch.db(dbname).allDocs({
>         include_docs: true,
>         success: function(data) {
>             data = _.map(data.rows, function(v) {
>                 return v.doc;
>             });
>             // Remove the design documents
>             data = _.filter(data, function(doc) { return (doc._id.substring(0,8) != "_design/");
});
>             // transform each document by a "transform" function
>             data = _.map(data, transform);
>             // If the function gave back null value, filter them out (they are considered
as not modified)
>             data = _.filter(data, function(doc) { return (doc != null); });
>             if (data.length == 0) {
>                 // no record left, nothing to do...
>                 return 0;
>             }
>             var bulk = { all_or_nothing: true, docs: data };
>             // Check the result
>             console.log(bulk);
>             if (typeof(commit) == 'undefined')
>                 return
>             // If commit, save the bulk in the db
>             if (commit) {
>                 jQuery.couch.db(dbname).bulkSave(bulk, {
>                     success: function() {
>                           // youpee, it worked
>                     }
>                 });
>             }
>         }
>     });
> };
> As far as I understand, the question is to be able to put that function in the futon
interface... and render results in the same styleguide than the other panels.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message