MCPcopy
hub / github.com/apache/pouchdb / onGetMetadata

Function onGetMetadata

lib/index.es.js:5942–5993  ·  view source on GitHub ↗
(metadata)

Source from the content-addressed store, hash-verified

5940 var metadata;
5941
5942 function onGetMetadata(metadata) {
5943 var winningRev$$1 = getWinningRev(metadata);
5944
5945 function onGetWinningDoc(winningDoc) {
5946
5947 var change = opts.processChange(winningDoc, metadata, opts);
5948 change.seq = metadata.seq;
5949
5950 var filtered = filter(change);
5951 if (typeof filtered === 'object') {
5952 return opts.complete(filtered);
5953 }
5954
5955 if (filtered) {
5956 called++;
5957
5958 if (opts.attachments && opts.include_docs) {
5959 // fetch attachment immediately for the benefit
5960 // of live listeners
5961 fetchAttachments([change], stores, opts).then(function () {
5962 opts.onChange(change);
5963 });
5964 } else {
5965 opts.onChange(change);
5966 }
5967
5968 if (opts.return_docs) {
5969 results.push(change);
5970 }
5971 }
5972 next();
5973 }
5974
5975 if (metadata.seq !== seq) {
5976 // some other seq is later
5977 return next();
5978 }
5979
5980 lastSeq = seq;
5981
5982 if (winningRev$$1 === doc._rev) {
5983 return onGetWinningDoc(doc);
5984 }
5985
5986 // fetch the winner
5987
5988 var winningSeq = metadata.rev_map[winningRev$$1];
5989
5990 stores.bySeqStore.get(formatSeq(winningSeq), function (err, doc) {
5991 onGetWinningDoc(doc);
5992 });
5993 }
5994
5995 metadata = docIdsToMetadata.get(doc._id);
5996 if (metadata) { // cached

Callers 1

LevelPouchFunction · 0.70

Calls 5

getWinningRevFunction · 0.70
nextFunction · 0.70
onGetWinningDocFunction · 0.70
formatSeqFunction · 0.70
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…