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

Function onGetMetadata

lib/index.js:5947–5998  ·  view source on GitHub ↗
(metadata)

Source from the content-addressed store, hash-verified

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