Migwell
Migwell

Reputation: 20147

Is it possible to get CouchDB to exclude the 'internal' fields _id and _rev when emitting data?

Basically what it says in the title.

Any program making use of my database has no need of the current revision information and how I have labelled the document internally, and including them can hinder iteration over meaningful properties. So why is it included when you make a GET request for a specific document?

Is it possible to get CouchDB to exclude this information?

Upvotes: 2

Views: 927

Answers (1)

Simon
Simon

Reputation: 32943

Sure, just query the DB through a show function that filters any undesired fields.

Something like:

function(doc, req) {
  delete doc._id;
  delete doc._rev;
  provides('json', function() {
    return {'json': doc};
  });
}

Upvotes: 2

Related Questions