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

Function idbAllDocs

lib/index-browser.js:5459–5627  ·  view source on GitHub ↗
(opts, idb, callback)

Source from the content-addressed store, hash-verified

5457}
5458
5459function idbAllDocs(opts, idb, callback) {
5460 var start = 'startkey' in opts ? opts.startkey : false;
5461 var end = 'endkey' in opts ? opts.endkey : false;
5462 var key = 'key' in opts ? opts.key : false;
5463 var keys = 'keys' in opts ? opts.keys : false;
5464 var skip = opts.skip || 0;
5465 var limit = typeof opts.limit === 'number' ? opts.limit : -1;
5466 var inclusiveEnd = opts.inclusive_end !== false;
5467
5468 var keyRange ;
5469 var keyRangeError;
5470 if (!keys) {
5471 keyRange = createKeyRange(start, end, inclusiveEnd, key, opts.descending);
5472 keyRangeError = keyRange && keyRange.error;
5473 if (keyRangeError &&
5474 !(keyRangeError.name === "DataError" && keyRangeError.code === 0)) {
5475 // DataError with error code 0 indicates start is less than end, so
5476 // can just do an empty query. Else need to throw
5477 return callback(createError(IDB_ERROR,
5478 keyRangeError.name, keyRangeError.message));
5479 }
5480 }
5481
5482 var stores = [DOC_STORE, BY_SEQ_STORE, META_STORE];
5483
5484 if (opts.attachments) {
5485 stores.push(ATTACH_STORE);
5486 }
5487 var txnResult = openTransactionSafely(idb, stores, 'readonly');
5488 if (txnResult.error) {
5489 return callback(txnResult.error);
5490 }
5491 var txn = txnResult.txn;
5492 txn.oncomplete = onTxnComplete;
5493 txn.onabort = idbError(callback);
5494 var docStore = txn.objectStore(DOC_STORE);
5495 var seqStore = txn.objectStore(BY_SEQ_STORE);
5496 var metaStore = txn.objectStore(META_STORE);
5497 var docIdRevIndex = seqStore.index('_doc_id_rev');
5498 var results = [];
5499 var docCount;
5500 var updateSeq;
5501
5502 metaStore.get(META_STORE).onsuccess = function (e) {
5503 docCount = e.target.result.docCount;
5504 };
5505
5506 /* istanbul ignore if */
5507 if (opts.update_seq) {
5508 // get max updateSeq
5509 seqStore.openKeyCursor(null, 'prev').onsuccess = e => {
5510 var cursor = e.target.result;
5511 if (cursor && cursor.key) {
5512 updateSeq = cursor.key;
5513 }
5514 };
5515 }
5516

Callers 1

initFunction · 0.70

Calls 8

createKeyRangeFunction · 0.70
createErrorFunction · 0.70
openTransactionSafelyFunction · 0.70
idbErrorFunction · 0.70
allDocsKeysFunction · 0.70
getAllFunction · 0.70
runBatchedCursorFunction · 0.70
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…