Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// store the value of update_seq in the by-sequence store the key name will
// never conflict, since the keys in the by-sequence store are integers
var UPDATE_SEQ_KEY = '_local_last_update_seq';
var DOC_COUNT_KEY = '_local_doc_count';
var UUID_KEY = '_local_uuid';
var MD5_PREFIX = 'md5-';
var safeJsonEncoding = {
encode: pouchdbJson.safeJsonStringify,
decode: pouchdbJson.safeJsonParse,
buffer: false,
type: 'cheap-json'
};
var levelChanges = new pouchdbUtils.changesHandler();
// winningRev and deleted are performance-killers, but
// in newer versions of PouchDB, they are cached on the metadata
function getWinningRev(metadata) {
return 'winningRev' in metadata ?
metadata.winningRev : pouchdbMerge.winningRev(metadata);
}
function getIsDeleted(metadata, winningRev) {
return 'deleted' in metadata ?
metadata.deleted : pouchdbAdapterUtils.isDeleted(metadata, winningRev);
}
function fetchAttachment(att, stores, opts) {
var type = att.content_type;
return new Promise(function (resolve, reject) {
// API implementations
import info from './info';
import get from './get';
import getAttachment from './getAttachment';
import bulkDocs from './bulkDocs';
import allDocs from './allDocs';
import changes from './changes';
import getRevisionTree from './getRevisionTree';
import doCompaction from './doCompaction';
import destroy from './destroy';
var ADAPTER_NAME = 'indexeddb';
// TODO: Constructor should be capitalised
var idbChanges = new changesHandler();
// A shared list of database handles
var openDatabases = {};
function IdbPouch(dbOpts, callback) {
var api = this;
var metadata = {};
// This is a wrapper function for any methods that need an
// active database handle it will recall itself but with
// the database handle as the first argument
var $ = function (fun) {
return function () {
var args = Array.prototype.slice.call(arguments);
setup(openDatabases, api, dbOpts).then(function (res) {
import get from './get';
import { getAttachment } from './getAttachment';
import bulkDocs from './bulkDocs';
import allDocs from './allDocs';
import changes from './changes';
import getRevisionTree from './getRevisionTree';
import doCompaction from './doCompaction';
import destroy from './destroy';
import {query, viewCleanup} from './find';
import { DOC_STORE } from './util';
var ADAPTER_NAME = 'indexeddb';
// TODO: Constructor should be capitalised
var idbChanges = new changesHandler();
// A shared list of database handles
var openDatabases = {};
function IdbPouch(dbOpts, callback) {
var api = this;
var metadata = {};
// Wrapper that gives you an active DB handle. You probably want $t.
var $ = function (fun) {
return function () {
var args = Array.prototype.slice.call(arguments);
setup(openDatabases, api, dbOpts).then(function (res) {
metadata = res.metadata;
args.unshift(res.idb);
// store the value of update_seq in the by-sequence store the key name will
// never conflict, since the keys in the by-sequence store are integers
var UPDATE_SEQ_KEY = '_local_last_update_seq';
var DOC_COUNT_KEY = '_local_doc_count';
var UUID_KEY = '_local_uuid';
var MD5_PREFIX = 'md5-';
var safeJsonEncoding = {
encode: safeJsonStringify,
decode: safeJsonParse,
buffer: false,
type: 'cheap-json'
};
var levelChanges = new Changes();
// winningRev and deleted are performance-killers, but
// in newer versions of PouchDB, they are cached on the metadata
function getWinningRev(metadata) {
return 'winningRev' in metadata ?
metadata.winningRev : calculateWinningRev(metadata);
}
function getIsDeleted(metadata, winningRev) {
return 'deleted' in metadata ?
metadata.deleted : isDeleted(metadata, winningRev);
}
function fetchAttachment(att, stores, opts) {
var type = att.content_type;
return new Promise(function (resolve, reject) {
// store the value of update_seq in the by-sequence store the key name will
// never conflict, since the keys in the by-sequence store are integers
var UPDATE_SEQ_KEY = '_local_last_update_seq';
var DOC_COUNT_KEY = '_local_doc_count';
var UUID_KEY = '_local_uuid';
var MD5_PREFIX = 'md5-';
var safeJsonEncoding = {
encode: pouchdbJson.safeJsonStringify,
decode: pouchdbJson.safeJsonParse,
buffer: false,
type: 'cheap-json'
};
var levelChanges = new pouchdbUtils.changesHandler();
// winningRev and deleted are performance-killers, but
// in newer versions of PouchDB, they are cached on the metadata
function getWinningRev(metadata) {
return 'winningRev' in metadata ?
metadata.winningRev : pouchdbMerge.winningRev(metadata);
}
function getIsDeleted(metadata, winningRev) {
return 'deleted' in metadata ?
metadata.deleted : pouchdbAdapterUtils.isDeleted(metadata, winningRev);
}
function fetchAttachment(att, stores, opts) {
var type = att.content_type;
return new Promise(function (resolve, reject) {
// store the value of update_seq in the by-sequence store the key name will
// never conflict, since the keys in the by-sequence store are integers
var UPDATE_SEQ_KEY = '_local_last_update_seq';
var DOC_COUNT_KEY = '_local_doc_count';
var UUID_KEY = '_local_uuid';
var MD5_PREFIX = 'md5-';
var safeJsonEncoding = {
encode: safeJsonStringify,
decode: safeJsonParse,
buffer: false,
type: 'cheap-json'
};
var levelChanges = new Changes();
// winningRev and deleted are performance-killers, but
// in newer versions of PouchDB, they are cached on the metadata
function getWinningRev(metadata) {
return 'winningRev' in metadata ?
metadata.winningRev : calculateWinningRev(metadata);
}
function getIsDeleted(metadata, winningRev) {
return 'deleted' in metadata ?
metadata.deleted : isDeleted(metadata, winningRev);
}
function fetchAttachment(att, stores, opts) {
var type = att.content_type;
return new Promise(function (resolve, reject) {
// store the value of update_seq in the by-sequence store the key name will
// never conflict, since the keys in the by-sequence store are integers
var UPDATE_SEQ_KEY = '_local_last_update_seq'
var DOC_COUNT_KEY = '_local_doc_count'
var UUID_KEY = '_local_uuid'
var MD5_PREFIX = 'md5-'
var safeJsonEncoding = {
encode: safeJsonStringify,
decode: safeJsonParse,
buffer: false,
type: 'cheap-json'
}
var levelChanges = new Changes()
// winningRev and deleted are performance-killers, but
// in newer versions of PouchDB, they are cached on the metadata
function getWinningRev (metadata) {
return 'winningRev' in metadata
? metadata.winningRev
: calculateWinningRev(metadata)
}
function getIsDeleted (metadata, winningRev) {
return 'deleted' in metadata
? metadata.deleted
: isDeleted(metadata, winningRev)
}
function fetchAttachment (att, stores, opts) {
} from './constants';
import {
qMarks,
stringifyDoc,
unstringifyDoc,
select,
compactRevs,
websqlError,
getSize,
unescapeBlob
} from './utils';
import openDB from './openDatabase';
var websqlChanges = new Changes();
function fetchAttachmentsIfNecessary(doc, opts, api, txn, cb) {
var attachments = Object.keys(doc._attachments || {});
if (!attachments.length) {
return cb && cb();
}
var numDone = 0;
function checkDone() {
if (++numDone === attachments.length && cb) {
cb();
}
}
function fetchAttachment(doc, att) {
var attObj = doc._attachments[att];
const resolveResult = meta => {
const result = {
storage,
meta: {
db_uuid: meta[0],
doc_count: meta[1],
update_seq: meta[2]
},
opts,
changes: new ChangesHandler()
}
openDatabases[opts.name] = result
resolve(result)
}