How to use the rxdb.plugin function in rxdb

To help you get started, we’ve selected a few rxdb 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 pubkey / rxdb / test / tutorials / src / typescript.ts View on Github external
/**
 * this is the test for the typescript-tutorial
 * IMPORTANT: whenever you change something here,
 * ensure it is also changed in /docs-src/tutorials/typescript.md
 */

// import types
import RxDB, {
    RxDatabase,
    RxCollection,
    RxJsonSchema,
    RxDocument
} from 'rxdb';

import * as MemoryAdapter from 'pouchdb-adapter-memory';
RxDB.plugin(MemoryAdapter);

/**
 * declare types
 */

type HeroDocType = {
    passportId: string;
    firstName: string;
    lastName: string;
    age?: number; // optional
};

type HeroDocMethods = {
    scream: (v: string) => string;
};
github salomonelli / nirania / src / services / database.service.js View on Github external
import * as RxDB from 'rxdb';
RxDB.plugin(require('pouchdb-adapter-idb'));
RxDB.plugin(require('pouchdb-replication')); //enable syncing
RxDB.plugin(require('pouchdb-adapter-http')); //enable syncing over http

const syncURL = 'http://' + window.location.hostname + ':10102/';
console.log('host: ' + syncURL);
// const syncURL = host;

let dbPromise = null;

const _create = async function() {
    console.log('DatabaseService: creating database..');
    const db = await RxDB.create({
        name: 'niraniadb',
        adapter: 'idb',
        password: 'myLongAndStupidPassword'
    });
github pubkey / rxdb / examples / react-native / App.js View on Github external
Text,
    View,
    Dimensions,
    StatusBar,
    Image,
    TextInput,
    TouchableOpacity,
} from 'react-native';
import React from 'react';
const { width, height } = Dimensions.get('window');

import { default as randomToken } from 'random-token';
import * as RxDB from 'rxdb';
import schema from './src/Schema';

RxDB.plugin(require('pouchdb-adapter-asyncstorage').default);
RxDB.plugin(require('pouchdb-adapter-http'));
const syncURL = 'http://localhost:10102/'; // Replace localhost with a public ip address!
const dbName = 'heroesreactdatabase1';

export default class App extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            heroes: [],
            name: '',
            color: 'steelblue',
            pouchWorks: null,
            col: null,
        };
        this.addHero = this.addHero.bind(this);
        this.col = null;
github thundernet8 / StarCabinet / src / renderer / rxdb / database.ts View on Github external
import * as RxDB from "rxdb";
import { RxDatabase, RxCollectionCreator } from "rxdb";
import logger from "../utils/logger";
import { extendRxDB } from "./dbExtension";
import repoSchema from "./schemas/repoSchema";
import authorSchema from "./schemas/authorSchema";
import meSchema from "./schemas/meSchema";
import tagSchema from "./schemas/tagSchema";
import categorySchema from "./schemas/categorySchema";
import languageSchema from "./schemas/languageSchema";
import settingSchema from "./schemas/settingSchema";

declare var window;

RxDB.plugin(require("pouchdb-adapter-idb"));

const collections: RxCollectionCreator[] = [
    {
        name: "repos",
        schema: repoSchema as any
    },
    {
        name: "authors",
        schema: authorSchema
        // sync: false
    },
    {
        name: "me",
        schema: meSchema
        // sync: false
    },
github eh3rrera / react-rxdb-example / src / App.js View on Github external
import './App.css';

import * as RxDB from 'rxdb';
import {QueryChangeDetector} from 'rxdb';
import { schema } from './Schema';

import { ToastContainer, toast } from 'react-toastify';
// The following line is not needed for react-toastify v3, only for v2.2.1
//import 'react-toastify/dist/ReactToastify.min.css';

import * as moment from 'moment';

QueryChangeDetector.enable();
QueryChangeDetector.enableDebugging();

RxDB.plugin(require('pouchdb-adapter-idb'));
RxDB.plugin(require('pouchdb-adapter-http'));

const syncURL = 'http://localhost:5984/';
const dbName = 'chatdb';

class App extends Component {

  constructor(props) {
    super(props);
    this.state = {
      newMessage: '', messages: []
    };
    this.subs = [];
    this.addMessage = this.addMessage.bind(this);
    this.handleMessageChange = this.handleMessageChange.bind(this);
  }
github pubkey / rxdb / examples / react-native / App.js View on Github external
View,
    Dimensions,
    StatusBar,
    Image,
    TextInput,
    TouchableOpacity,
} from 'react-native';
import React from 'react';
const { width, height } = Dimensions.get('window');

import { default as randomToken } from 'random-token';
import * as RxDB from 'rxdb';
import schema from './src/Schema';

RxDB.plugin(require('pouchdb-adapter-asyncstorage').default);
RxDB.plugin(require('pouchdb-adapter-http'));
const syncURL = 'http://localhost:10102/'; // Replace localhost with a public ip address!
const dbName = 'heroesreactdatabase1';

export default class App extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            heroes: [],
            name: '',
            color: 'steelblue',
            pouchWorks: null,
            col: null,
        };
        this.addHero = this.addHero.bind(this);
        this.col = null;
        this.subs = [];
github decentralized-identity / element / packages / element-lib / src / adapters / database / ElementRXDBAdapter.js View on Github external
this.remote = remote;
    switch (adapter) {
      case 'browser':
        // eslint-disable-next-line
        RxDB.plugin(require('pouchdb-adapter-idb'));
        this.adapter = 'idb';
        break;
      case 'leveldown':
        // eslint-disable-next-line
        RxDB.plugin(require('pouchdb-adapter-leveldb')); // leveldown adapters need the leveldb plugin to work
        // eslint-disable-next-line
        this.adapter = require('leveldown');
        break;
      case 'memory':
        // eslint-disable-next-line
        RxDB.plugin(require('pouchdb-adapter-memory'));
        // eslint-disable-next-line
        RxDB.plugin(require('pouchdb-adapter-http'));
        this.adapter = 'memory';
        break;
      default:
    }
  }
github waynecz / dadda-translate-crx / src / db / index.ts View on Github external
import RxDB, { RxDatabase, RxCollection, RxJsonSchema, RxDocument } from 'rxdb'
import { TR_VOCABULARY_STORE_KEY } from '@configs/storage-keys'
import { DaddaDatabase, DaddaDatabaseCollections } from '@models/db';

RxDB.plugin(require('pouchdb-adapter-idb'))
;(async function() {
  const database: DaddaDatabase = await RxDB.create({
    name: TR_VOCABULARY_STORE_KEY,
    adapter: 'idb',
    multiInstance: true
  })

  database.collection({
    name: 'vocabulary',
    schema: {
      title: 'word',
      version: 0,
      type: 'object',
      properties: {
        text: {
          type: 'string'
github pubkey / rxdb / examples / electron / main.js View on Github external
const electron = require('electron');
require('electron-window-manager');
const path = require('path');
const url = require('url');
const database = require('./database');

const RxDB = require('rxdb');
RxDB.plugin(require('rxdb/plugins/server'));
RxDB.plugin(require('pouchdb-adapter-memory'));

const app = electron.app;
const BrowserWindow = electron.BrowserWindow;

const windows = [];

function createWindow(dbSuffix) {
    const width = 300;
    const height = 600;
    const w = new BrowserWindow({
        width,
        height,
        webPreferences: {
            nodeIntegration: true
        }
    });
github salomonelli / nirania / old / js / Database.js View on Github external
import 'babel-polyfill';
import * as RxDB from 'rxdb';
RxDB.plugin(require('pouchdb-adapter-idb'));

const DBName = 'niraniaDB2';
let DB, levelCollection, soundCollection;

const levelSchema = {
    title: 'level schema',
    description: 'describes a level',
    type: 'object',
    properties: {
        level: {
            type: 'string',
            primary: true
        },
        levelID: {
            type: 'number'
        },

rxdb

A local-first realtime NoSQL Database for JavaScript applications - https://rxdb.info/

Apache-2.0
Latest version published 5 days ago

Package Health Score

86 / 100
Full package analysis