Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import { types, getRoot, destroy } from "mobx-state-tree";
import { assignUUID } from "./Utils";
import { Alert } from "react-native";
import PouchDB from "pouchdb-react-native";
import SQLite from "react-native-sqlite-2";
import SQLiteAdapterFactory from "pouchdb-adapter-react-native-sqlite";
const SQLiteAdapter = SQLiteAdapterFactory(SQLite);
PouchDB.plugin(SQLiteAdapter);
const db = new PouchDB("printers.db", { adapter: "react-native-sqlite" });
const dbc = new PouchDB("company.db", { adapter: "react-native-sqlite" });
const dbb = new PouchDB("bluetoothscanner.db", {
adapter: "react-native-sqlite",
});
const dbd = new PouchDB("sync.db", {
adapter: "react-native-sqlite",
});
PouchDB.plugin(require("pouchdb-find"));
PouchDB.plugin(require("pouchdb-upsert"));
let rowsOptions = {};
export const Printer = types
.model("Printer", {
/**
* PouchDB using sqlite adapter
* see https://github.com/craftzdog/react-native-sqlite-2
*/
import PouchDB from 'pouchdb-react-native';
import SQLite from 'react-native-sqlite-2';
import SQLiteAdapterFactory from 'pouchdb-adapter-react-native-sqlite';
const SQLiteAdapter = SQLiteAdapterFactory(SQLite);
PouchDB.plugin(SQLiteAdapter);
export default function (dbName, options) {
return new PouchDB(dbName, Object.assign({ adapter: 'react-native-sqlite' }, options));
}
export function openAndSyncDB(dbName, withSync = false) {
const SQLiteAdapter = SQLiteAdapterFactory(SQLite);
PouchDB.plugin(SQLiteAdapter);
const db = new PouchDB(dbName + ".db", { adapter: "react-native-sqlite" });
PouchDB.plugin(require("pouchdb-find"));
PouchDB.plugin(require("pouchdb-upsert"));
return db;
}