Eventing on same bucket document

how to remove any field from document using eventing on same source bucket.

My task is to remove specific field form all documents in a bucket. (Note: direct N1QL query is not useful as it is taking a lot of time. So thought of eventing but unable to get any solution)

Hi Nitesh,

You will need Couchbase 6.5 or later to do this. Let’s say you want to remove field “remove_this” from documents in bucket named “my_bucket”. Here’s how you’d configure the eventing handler:

Source Bucket:
Set source bucket to the bucket of interest, my_bucket

Define this alias in function settings to allow the function to write to the bucket:
AliasName = bkt, Bucket = my_bucket, Access = Read+Write


function OnUpdate(doc, meta) {
  if (doc.removethis) {
    delete doc.removethis; // remove the field
    bkt[meta.id] = doc; // write it back to the bucket

If you wish to speed it up, you can add more eventing nodes to the cluster.

Best Regards,

Thanks for letting me know that source bucket mutation does not work in CB <6.5 eventings.