How to use the pouchdb-utils.uuid function in pouchdb-utils

To help you get started, we’ve selected a few pouchdb-utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pouchdb / pouchdb / packages / node_modules / pouchdb-replication / src / replicate.js View on Github external
}; // next batch, not yet ready to be processed
  var writingCheckpoint = false;  // true while checkpoint is being written
  var changesCompleted = false;   // true when all changes received
  var replicationCompleted = false; // true when replication has completed
  var last_seq = 0;
  var continuous = opts.continuous || opts.live || false;
  var batch_size = opts.batch_size || 100;
  var batches_limit = opts.batches_limit || 10;
  var changesPending = false;     // true while src.changes is running
  var doc_ids = opts.doc_ids;
  var selector = opts.selector;
  var repId;
  var checkpointer;
  var changedDocs = [];
  // Like couchdb, every replication gets a unique session id
  var session = uuid();

  result = result || {
    ok: true,
    start_time: new Date().toISOString(),
    docs_read: 0,
    docs_written: 0,
    doc_write_failures: 0,
    errors: []
  };

  var changesOpts = {};
  returnValue.ready(src, target);

  function initCheckpointer() {
    if (checkpointer) {
      return Promise.resolve();
github pouchdb / pouchdb / packages / node_modules / pouchdb-adapter-websql-core / src / index.js View on Github external
tx.executeSql(meta, [], function () {
            // mark the db version, and new dbid
            var initSeq = 'INSERT INTO ' + META_STORE +
              ' (db_version, dbid) VALUES (?,?)';
            instanceId = uuid();
            var initSeqArgs = [ADAPTER_VERSION, instanceId];
            tx.executeSql(initSeq, initSeqArgs, function () {
              onGetInstanceId();
            });
          });
        });
github stockulus / pouchdb-react-native / packages / pouchdb-adapter-asyncstorage / src / changes.js View on Github external
export default function(db, api, opts) {
  const continuous = opts.continuous

  if (continuous) {
    const id = db.opts.name + ':' + uuid()
    db.changes.addListener(db.opts.name, id, api, opts)
    db.changes.notify(db.opts.name)
    return {
      cancel() {
        db.changes.removeListener(db.opts.name, id)
      }
    }
  }

  //  const descending = opts.descending
  const lastSeq = opts.since || 0
  const limit = 'limit' in opts && opts.limit >= 0 ? opts.limit : -1
  const filterDocIds = opts.doc_ids && new Set(opts.doc_ids)
  const returnDocs =
    'return_docs' in opts
      ? opts.return_docs
github pouchdb / pouchdb / packages / node_modules / pouchdb-adapter-indexeddb / src / changes.js View on Github external
export default function (txn, idbChanges, api, dbOpts, opts) {
  if (txn.error) {
    return opts.complete(txn.error);
  }

  if (opts.continuous) {
    var id = dbOpts.name + ':' + uuid();
    idbChanges.addListener(dbOpts.name, id, api, opts);
    idbChanges.notify(dbOpts.name);
    return {
      cancel: function () {
        idbChanges.removeListener(dbOpts.name, id);
      }
    };
  }

  var limit = 'limit' in opts ? opts.limit : -1;
  if (limit === 0) {
    limit = 1;
  }

  var store = txn.txn.objectStore(DOC_STORE).index('seq');
github pouchdb / pouchdb / packages / node_modules / pouchdb-adapter-idb / src / index.js View on Github external
function storeMetaDocIfReady() {
      if (typeof docCount === 'undefined' || typeof metaDoc === 'undefined') {
        return;
      }
      var instanceKey = dbName + '_id';
      if (instanceKey in metaDoc) {
        instanceId = metaDoc[instanceKey];
      } else {
        metaDoc[instanceKey] = instanceId = uuid();
      }
      metaDoc.docCount = docCount;
      txn.objectStore(META_STORE).put(metaDoc);
    }
github stockulus / pouchdb-react-native / packages / pouchdb-adapter-leveldb-core-rn / lib / index.js View on Github external
api._changes = function (opts) {
    opts = pouchdbUtils.clone(opts);

    if (opts.continuous) {
      var id = name + ':' + pouchdbUtils.uuid();
      levelChanges.addListener(name, id, api, opts);
      levelChanges.notify(name);
      return {
        cancel: function () {
          levelChanges.removeListener(name, id);
        }
      };
    }

    var descending = opts.descending;
    var results = [];
    var lastSeq = opts.since || 0;
    var called = 0;
    var streamOpts = {
      reverse: descending
    };
github stockulus / pouchdb-react-native / packages / pouchdb-adapter-leveldb-core-rn / lib / index-browser.js View on Github external
stores.metaStore.get(UUID_KEY, function (err, value) {
            instanceId = !err ? value : pouchdbUtils.uuid();
            stores.metaStore.put(UUID_KEY, instanceId, function () {
              process.nextTick(function () {
                callback(null, api);
              });
            });
          });
        });
github stockulus / pouchdb-react-native / packages / pouchdb-adapter-leveldb-core-rn / src / index.js View on Github external
api._changes = function (opts) {
    opts = clone(opts);

    if (opts.continuous) {
      var id = name + ':' + uuid();
      levelChanges.addListener(name, id, api, opts);
      levelChanges.notify(name);
      return {
        cancel: function () {
          levelChanges.removeListener(name, id);
        }
      };
    }

    var descending = opts.descending;
    var results = [];
    var lastSeq = opts.since || 0;
    var called = 0;
    var streamOpts = {
      reverse: descending
    };
github stockulus / pouchdb-react-native / packages / pouchdb-adapter-leveldb-core-rn / src / index.js View on Github external
stores.metaStore.get(UUID_KEY, function (err, value) {
            instanceId = !err ? value : uuid();
            stores.metaStore.put(UUID_KEY, instanceId, function () {
              process.nextTick(function () {
                callback(null, api);
              });
            });
          });
        });
github stockulus / pouchdb-react-native / packages / pouchdb-adapter-leveldb-core-rn / lib / index.js View on Github external
stores.metaStore.get(UUID_KEY, function (err, value) {
            instanceId = !err ? value : pouchdbUtils.uuid();
            stores.metaStore.put(UUID_KEY, instanceId, function () {
              process.nextTick(function () {
                callback(null, api);
              });
            });
          });
        });