How to use pouchdb-core - 10 common examples

To help you get started, we’ve selected a few pouchdb-core 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 jrs-innovation-center / tcvsn-pwa / api / load-indexes.js View on Github external
require('dotenv').config()
const PouchDB = require('pouchdb-core')
PouchDB.plugin(require('pouchdb-adapter-mysql'))
PouchDB.plugin(require('pouchdb-find'))

const db = new PouchDB('data', { adapter: 'mysql' })

// sort the docs by the type property
db
  .createIndex({ index: { fields: ['type'] } })
  .then(() => {
    console.log('Created an index on the type field.')
  })
  .catch(err => console.log(err))

// sort the docs by the name property
db
  .createIndex({ index: { fields: ['name'] } })
  .then(() => {
github TankerHQ / quickstart-examples / client / nodejs / hello-world / persistence.js View on Github external
const fs = require('fs');
const PouchDBCore = require('pouchdb-core');
const PouchDBAdapterLevel = require('pouchdb-adapter-leveldb');
const PouchDBFind = require('pouchdb-find');

const tankerConfig = require('./config');

PouchDBCore.plugin(PouchDBAdapterLevel);
PouchDBCore.plugin(PouchDBFind);

// Custom setup to persist data with PouchDB in Node.js (not needed when
// using the tanker SDK in a browser application).
module.exports = {
  config: {
    PouchDB: function (dbName) {
      // Folder to store tokens for this trustchain
      const folder = `./data/${tankerConfig.trustchainId.replace(/[\/\\]/g, '_')}`;

      // Ensure folder exists
      if (!fs.existsSync(folder)) {
        fs.mkdirSync(folder);
      }

      // Apply defaults
      const PouchDB = PouchDBCore.defaults({ adapter: 'leveldb' });
github apache / couchdb-fauxton / app / addons / documents / rev-browser / actions.js View on Github external
//
//   http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations under
// the License.

import FauxtonAPI from "../../../core/api";
import {post} from "../../../core/ajax";
import ActionTypes from "./actiontypes";
import getTree from "visualize-rev-tree/lib/getTree";
import PouchDB from "pouchdb-core";
import PouchHttpAdapter from 'pouchdb-adapter-http';
PouchDB.plugin(PouchHttpAdapter);

let db;

export const initDiffEditor = (dbName, docId) => dispatch => {
  // We have to use API url here because PouchDB doesn't take relative urls.
  const url = FauxtonAPI.urls('databaseBaseURL', 'apiurl', dbName);
  db = PouchDB(url);

  Promise.all([db.get(docId), getTree(db, docId)])
    .then(([doc, tree]) => {
      const conflictingRevs = getConflictingRevs(tree.paths, tree.winner, Object.keys(tree.deleted));
      const initialRev = conflictingRevs[0];

      if (!initialRev) {
        return dispatch(treeLoaded(tree, doc, conflictingRevs, null, dbName));
      }
github nolanlawson / pokedex.org / src / js / worker / pouchdb.js View on Github external
// custom version of pouchdb cutting out stuff we don't need

import PouchDB from 'pouchdb-core';
import idb from 'pouchdb-adapter-idb';
import websql from 'pouchdb-adapter-websql';
import http from 'pouchdb-adapter-http';
import upsert from 'pouchdb-upsert';
import load from 'pouchdb-load';

export default PouchDB
  .plugin(idb)
  .plugin(websql)
  .plugin(http)
  .plugin(upsert)
  .plugin(load);
github paperize / paperize / lib / services / pouch.js View on Github external
import PouchDB from 'pouchdb-core'

// All Environments
let configuredPouch = PouchDB
  .plugin(require('pouchdb-find').default)

if(process.env["NODE_ENV"] === 'test' && typeof window === 'undefined') {
  // Node tests, include extra libs for speed
  configuredPouch
    .plugin(require('pouchdb-adapter-memory').default)
  configuredPouch = configuredPouch.defaults({ adapter: 'memory' })
} else {
  // Any environment with a window
  configuredPouch
    .plugin(require('pouchdb-adapter-idb').default)
    .plugin(require('pouchdb-adapter-websql').default)
}

export default configuredPouch
github apache / couchdb-fauxton / app / addons / documents / rev-browser / actions.js View on Github external
export const initDiffEditor = (dbName, docId) => dispatch => {
  // We have to use API url here because PouchDB doesn't take relative urls.
  const url = FauxtonAPI.urls('databaseBaseURL', 'apiurl', dbName);
  db = PouchDB(url);

  Promise.all([db.get(docId), getTree(db, docId)])
    .then(([doc, tree]) => {
      const conflictingRevs = getConflictingRevs(tree.paths, tree.winner, Object.keys(tree.deleted));
      const initialRev = conflictingRevs[0];

      if (!initialRev) {
        return dispatch(treeLoaded(tree, doc, conflictingRevs, null, dbName));
      }

      db.get(doc._id, {rev: initialRev})
        .then((conflictDoc) => {
          dispatch(treeLoaded(tree, doc, conflictingRevs, conflictDoc, dbName));
        });
    });
};
github TankerHQ / quickstart-examples / client / nodejs / hello-world / persistence.js View on Github external
PouchDB: function (dbName) {
      // Folder to store tokens for this trustchain
      const folder = `./data/${tankerConfig.trustchainId.replace(/[\/\\]/g, '_')}`;

      // Ensure folder exists
      if (!fs.existsSync(folder)) {
        fs.mkdirSync(folder);
      }

      // Apply defaults
      const PouchDB = PouchDBCore.defaults({ adapter: 'leveldb' });

      // PouchDB will now persist data in the proper folder
      return new PouchDB(`${folder}/${dbName}`);
    }
  }
github neighbourhoodie / voice-of-interconnect / bin / couch-doctor.js View on Github external
const url = require('url')

const PouchDB = require('pouchdb-core')
  .plugin(require('pouchdb-adapter-http'))
const SpeechToTextV1 = require('watson-developer-cloud/speech-to-text/v1')
const NaturalLanguageUnderstandingV1 = require('watson-developer-cloud/natural-language-understanding/v1.js')
const stream = require('stream')
const ffmpeg = require('fluent-ffmpeg')

const [couchUrl, dbName] = process.argv.slice(2)
const {
  SPEECH_TO_TEXT_USERNAME,
  SPEECH_TO_TEXT_PASSWORD,
  NATURAL_LANGUAGE_UNDERSTANDING_USERNAME,
  NATURAL_LANGUAGE_UNDERSTANDING_PASSWORD
} = process.env

if (!couchUrl) {
  console.log('Usage: node bin/couch-doctor.js https://user:password@couchhost.com [dbName]')
github oknosoft / metadata.js / packages / metadata-pouchdb / index.js View on Github external
let PouchDB;
if(typeof process !== 'undefined' && process.versions && process.versions.node) {
  PouchDB = require('pouchdb-core')
    .plugin(require('pouchdb-adapter-http'))
    .plugin(require('pouchdb-replication'))
    .plugin(require('pouchdb-mapreduce'))
    .plugin(require('pouchdb-find'))
    .plugin(require('pouchdb-adapter-memory'));
}
else {
  if(window.PouchDB) {
    PouchDB = window.PouchDB;
  }
  else {
    PouchDB = window.PouchDB = require('pouchdb-core').default
      .plugin(require('pouchdb-adapter-http').default)
      .plugin(require('pouchdb-replication').default)
      .plugin(require('pouchdb-mapreduce').default)
      .plugin(require('pouchdb-find').default)
      .plugin(require('pouchdb-adapter-idb').default);
  }
}
var PouchDB$1 = PouchDB;

function adapter({AbstracrAdapter}) {
  const fieldsToDelete = '_id,search,timestamp'.split(',');
  return class AdapterPouch extends AbstracrAdapter {
    constructor($p) {
      super($p);
      this.props = {
        _data_loaded: false,
github pouchdb / pouchdb / packages / node_modules / pouchdb-browser / src / index.js View on Github external
import PouchDB from 'pouchdb-core';

import IDBPouch from 'pouchdb-adapter-idb';
import HttpPouch from 'pouchdb-adapter-http';
import mapreduce from 'pouchdb-mapreduce';
import replication from 'pouchdb-replication';

PouchDB.plugin(IDBPouch)
  .plugin(HttpPouch)
  .plugin(mapreduce)
  .plugin(replication);

export default PouchDB;

pouchdb-core

The core of PouchDB as a standalone package.

Apache-2.0
Latest version published 6 months ago

Package Health Score

85 / 100
Full package analysis

Similar packages