How to use the nativescript-sqlite.copyDatabase function in nativescript-sqlite

To help you get started, we’ve selected a few nativescript-sqlite 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 bradyhouse / house / fiddles / nativeScript / fiddle-0009-SqliteDb / puzzle / platforms / ios / puzzle / app / shared / db.service.js View on Github external
function onCreateConnection(fn, scope) {
  consoleLogMsg("db.service", "createConnection");
  if (!Sqlite.exists(dbFile)) {
    Sqlite.copyDatabase(dbFile);
  }
  dbPromise = new Sqlite(dbName, function (err, dbConnection) {
    if (err) {
      console.error(err);
    } else {
      dbConnection.resultType(Sqlite.RESULTSASOBJECT);
      if (typeof fn === "function") {
        if (scope) {
          fn.apply(scope, [dbConnection]);
        } else {
          fn(dbConnection);
        }
      }
      dbConnection.close();
    }
  });
github NathanaelA / nativescript-sqlite / demo / app / main-page.js View on Github external
exports.pageLoaded = function(args) {
	page = args.object;
	page.bindingContext = {names: data};

	if (!sqlite.exists(dbname)) {
		sqlite.copyDatabase(dbname);
	}
	new sqlite(dbname, {key: 'testing', multithreading: !!sqlite.HAS_COMMERCIAL, migrate: true}, function(err, dbConnection) {
		if (err) {
			console.log(err, err.stack);
		}
		db = dbConnection;
		db.resultType(sqlite.RESULTSASOBJECT);

		db.version().then(function (results) {
			console.log("User Version: ", results, typeof results, Number.isNumber(results)); //, String.isString(results));
		});

		if (sqlite.HAS_ENCRYPTION) {
			db.get("PRAGMA cipher_version;").then(function(results) {
				console.log("Cipher version", results['cipher_version']);
			});
github bradyhouse / house / fiddles / nativeScript / fiddle-0011-SqliteNg2 / puzzle / app / app.component.ts View on Github external
public constructor() {
        if (!Sqlite.exists("highscore.db")) {
            Sqlite.copyDatabase("highscore.db");
        }
    }
github bradyhouse / house / fiddles / nativeScript / fiddle-0011-SqliteNg2 / puzzle / app / app.component.js View on Github external
function AppComponent() {
        if (!Sqlite.exists("highscore.db")) {
            Sqlite.copyDatabase("highscore.db");
        }
    }
    return AppComponent;