Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
/**
* 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;
};
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'
});
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;
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
},
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);
}
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 = [];
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:
}
}
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'
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
}
});
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'
},