MCPcopy
hub / github.com/louischatriot/nedb / getItem

Function getItem

browser-version/out/nedb.js:6751–6785  ·  view source on GitHub ↗
(key, callback)

Source from the content-addressed store, hash-verified

6749 }
6750
6751 function getItem(key, callback) {
6752 var self = this;
6753
6754 // Cast the key to a string, as that's all we can set as a key.
6755 if (typeof key !== 'string') {
6756 globalObject.console.warn(key + ' used as a key, but it is not a string.');
6757 key = String(key);
6758 }
6759
6760 var promise = new Promise(function (resolve, reject) {
6761 self.ready().then(function () {
6762 var dbInfo = self._dbInfo;
6763 var store = dbInfo.db.transaction(dbInfo.storeName, 'readonly').objectStore(dbInfo.storeName);
6764 var req = store.get(key);
6765
6766 req.onsuccess = function () {
6767 var value = req.result;
6768 if (value === undefined) {
6769 value = null;
6770 }
6771 if (_isEncodedBlob(value)) {
6772 value = _decodeBlob(value);
6773 }
6774 resolve(value);
6775 };
6776
6777 req.onerror = function () {
6778 reject(req.error);
6779 };
6780 })['catch'](reject);
6781 });
6782
6783 executeCallback(promise, callback);
6784 return promise;
6785 }
6786
6787 // Iterate over all items stored in database.
6788 function iterate(iterator, callback) {

Callers

nothing calls this directly

Calls 5

_isEncodedBlobFunction · 0.70
_decodeBlobFunction · 0.70
resolveFunction · 0.70
rejectFunction · 0.70
executeCallbackFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…