How to use the pouchdb function in pouchdb

To help you get started, we’ve selected a few pouchdb 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 Tangerine-Community / Tangerine / client / app / src / app / app.component.ts View on Github external
async checkIfUpdateScriptRequired() {
    const usersDb = new PouchDB('users');
    const response = await usersDb.allDocs({ include_docs: true });
    const usernames = response
      .rows
      .map(row => row.doc)
      .filter(doc => doc.hasOwnProperty('username'))
      .map(doc => doc.username);
    for (const username of usernames) {
      const userDb = await new PouchDB(username);
      // Use try in case this is an old account where info doc was not created.
      let infoDoc = { _id: '', atUpdateIndex: 0 };
      try {
        infoDoc = await userDb.get('info');
      } catch (e) {
        await userDb.put({ _id: 'info', atUpdateIndex: 0 });
        infoDoc = await userDb.get('info');
      }
      const atUpdateIndex = infoDoc.hasOwnProperty('atUpdateIndex') ? infoDoc.atUpdateIndex : 0;
      const lastUpdateIndex = updates.length - 1;
      if (lastUpdateIndex !== atUpdateIndex) {
        this.router.navigate(['/update']);
      }
    }
  }
github ArnoSaine / react-pouchdb / src / __tests__ / Get.js View on Github external
asyncTest(async done => {
      expect.assertions(3);
      const db = new PouchDBModule('test');
      const { rev } = await db.post({ _id: 'test', a: 'moo' });
      await db.putAttachment(
        'test',
        'att.txt',
        rev,
        Buffer.from('Moo?', 'utf8'),
        'text/plain'
      );
      const App = () => (
         do {
              expect(format(attachments['att.txt'].data)).toBe(value1);
              db.putAttachment(
github Tangerine-Community / Tangerine / client / src / app / core / sync-records / _services / syncing.service.ts View on Github external
async getAllUsersDocs(username?: string) {
    const userDB = username || await this.getLoggedInUser();
    const DB = new PouchDB(userDB);
    try {
      const result = await DB.allDocs({
        include_docs: true,
        attachments: true
      });
      return result;
    } catch (err) {
      console.log(err);
    }
  }
  async markDocsAsUploaded(replicatedDocIds, username) {
github Aedron / Luoo.qy / view / src / db / vol.ts View on Github external
import PouchDB from "pouchdb";
import PouchDBFind from "pouchdb-find";
import { VolInfo } from "../types";
import { getIPC } from "../utils";

PouchDB.plugin(PouchDBFind);

const db: PouchDB.Database = new PouchDB("vols");

db.createIndex({
  index: {
    fields: ["vol", "id"]
  }
});

class VolDB {
  public init = async () => {
    const ipc = await getIPC();
    const vols = ipc.getPreloadVols();
    console.time("save");
    await this.saveVols(vols);
    console.timeEnd("save");
    await this.getLatestVol();
  };
github compactd / compactd / client / src / features / library / library.tsx View on Github external
return Promise.resolve().then(() => {
    const artists = new PouchDB('artists');
    return artists.allDocs({
      include_docs: false,
      startkey: 'library/',
      endkey: 'library/\uffff'
    });
  }).then((docs) => {
    return {
github xMartin / grouptabs / src / db / tab.js View on Github external
constructor: function (localDbName, remoteDbLocation, changesCallback) {
    if (!localDbName || typeof localDbName !== 'string') {
      throw new Error('missing localDbName parameter');
    }

    if (!remoteDbLocation || typeof remoteDbLocation !== 'string') {
      throw new Error('missing remoteDbLocation parameter');
    }

    this.remoteDbLocation = remoteDbLocation;

    this._onChangesHandler = changesCallback;

    this.db = new PouchDB(localDbName);
    this.remoteDb = new PouchDB(remoteDbLocation);
  },
github Tangerine-Community / Tangerine / client / src / app / class / _services / class-form.service.ts View on Github external
constructor(props) {
    this.databaseName = 'tangy-class'
    Object.assign(this, props)
    this.userDB = new PouchDB(this.databaseName)
  }
github IBM / MAX-Image-Segmenter-Web-App / src / utils / index.js View on Github external
export const deleteAllImages = () => {
  const pouchDB = new PouchDB('offLine', { auto_compaction: true })
  return pouchDB.destroy()
}
github Tangerine-Community / Tangerine / client / shell / src / app / case-management / _services / case-management.service.ts View on Github external
constructor(
    authenticationService: AuthenticationService,
    loc: Loc,
    userService: UserService,
    private http: Http
  ) {
    this.loc = loc;
    this.userService = userService;
    this.userDB = new PouchDB
      (authenticationService.getCurrentUserDBPath());
  }
  async getMyLocationVisits() {
github compactd / compactd / client / src / app / content-decorator.tsx View on Github external
protected async fetchTrack (id: string): Promise {
    const Track = new PouchDB<track>('tracks');

    const track = await Track.get(id);
    
    return {
      type: this.RESOLVE_ALBUM,
      track
    }
  }
  /**