| 1516 | |
| 1517 | // clean docs given to us by the user |
| 1518 | function cleanDocs(docs) { |
| 1519 | for (var i = 0; i < docs.length; i++) { |
| 1520 | var doc = docs[i]; |
| 1521 | if (doc._deleted) { |
| 1522 | delete doc._attachments; // ignore atts for deleted docs |
| 1523 | } else if (doc._attachments) { |
| 1524 | // filter out extraneous keys from _attachments |
| 1525 | var atts = Object.keys(doc._attachments); |
| 1526 | for (var j = 0; j < atts.length; j++) { |
| 1527 | var att = atts[j]; |
| 1528 | doc._attachments[att] = pick(doc._attachments[att], |
| 1529 | ['data', 'digest', 'content_type', 'length', 'revpos', 'stub']); |
| 1530 | } |
| 1531 | } |
| 1532 | } |
| 1533 | } |
| 1534 | |
| 1535 | // compare two docs, first by _id then by _rev |
| 1536 | function compareByIdThenRev(a, b) { |