cloudant / nodejs-cloudant

Cloudant Node.js client library
Apache License 2.0
255 stars 90 forks source link

Save failed: `updates` cannot be used in a partitioned design doc #421

Closed armanriazi closed 4 years ago

armanriazi commented 4 years ago

I replicated from local CouchDB partitioned to a Cloudant partitioned and after that when I have tried edit document design rise error. Save failed: lists cannot be used in a partitioned design doc.


{
  "_id": "_design/system",
  "_rev": "29-0ded5d9d385a499f70b5ec5a76fea43b",
  "validate_doc_update": "function(new_doc,old_doc,userCtx){ if(userCtx.name !== 'admin' && userCtx.name!=='dbadmin') {throw {forbidden: 'Not Authorize'}} if(!new_doc._id){throw {forbidden: 'Name field is mandatory'}};}",
  "updates": {
    "timestamp": "function(doc,req){var currDate=new Date(Date.now()).toUTCString();doc['timestamp']=currDate;return [doc,'Added TimeStamp'];}",
    "numberinstock": "function(doc,req){doc.numberInStock = doc.numberInStock-1;var currDate=new Date(Date.now()).toUTCString();doc['timestamp']=currDate;doc['success']=true;return [doc,'true']}"
  },
  "lists": {
    "nametitle": "function(head,req){while (row=getRow()) {var nametitle=row.doc.name + ' ' + row.doc.title;row['nametitle']=nametitle;send(JSON.stringify(row));}}"
  }

}
bessbd commented 4 years ago

Hi @armanriazi ,

Thank you for this ticket! Unfortunately, the problems you are mentioning are not nodejs-cloudant issues. Neither updates, nor lists are allowed in partitioned design documents in Cloudant. See

I'd like to recommend finding a solution that does not depend on using updates or lists in partitioned design documents.