MCPcopy Index your code
hub / github.com/apache/pouchdb / postProcessAttachments

Function postProcessAttachments

lib/index-browser.js:4831–4854  ·  view source on GitHub ↗
(results, asBlob)

Source from the content-addressed store, hash-verified

4829// a base64-encoded string, and if it's a Blob it
4830// needs to be read outside of the transaction context
4831function postProcessAttachments(results, asBlob) {
4832 return Promise.all(results.map(function (row) {
4833 if (row.doc && row.doc._attachments) {
4834 var attNames = Object.keys(row.doc._attachments);
4835 return Promise.all(attNames.map(function (att) {
4836 var attObj = row.doc._attachments[att];
4837 if (!('body' in attObj)) { // already processed
4838 return;
4839 }
4840 var body = attObj.body;
4841 var type = attObj.content_type;
4842 return new Promise(function (resolve) {
4843 readBlobData(body, type, asBlob, function (data) {
4844 row.doc._attachments[att] = Object.assign(
4845 pick(attObj, ['digest', 'content_type']),
4846 {data}
4847 );
4848 resolve();
4849 });
4850 });
4851 }));
4852 }
4853 }));
4854}
4855
4856function compactRevs(revs, docId, txn) {
4857

Callers 2

onTxnCompleteFunction · 0.70

Calls 2

readBlobDataFunction · 0.70
pickFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…