Skip to content

Not all design fields are updated #1

@kanongil

Description

@kanongil

I was looking into replacing my custom baked design update functionality with this module but it is unusable for my task since it only detects changes to the views & updates fields.

FYI, I'm currently doing it like this, using the https://github.com/vkiryukhin/jsonfn-node module as a helper. Feel free to copy it if you want.

function updateDesign(db, name, design, cb) {
  var id = '_design/'+name;
  db.get(id, function(err, body, header) {
    if (err && err.reason === 'missing') {
      err = null;
      body = {};
    }
    if (err) throw err;

    var rev = body._rev;
    delete body._id;
    delete body._rev;

    if (JSONfn.stringify(design) === JSONfn.stringify(body))
      return cb(null);

    // design is changed!

    design._id = id;
    design._rev = rev;

    db.insert(new Buffer(JSONfn.stringify(design)), id, cb);
  });
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions