How to use the nativescript-sqlite.RESULTSASOBJECT 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 NathanaelA / nativescript-sqlite / demo / app / main-page.js View on Github external
function runNativeObjectTest(callback) {
	console.log("!--------------  Starting RNO Test");
	db.resultType(sqlite.RESULTSASOBJECT);
	db.valueType(sqlite.VALUESARENATIVE);

	const tests = [
		// Callback
		{name: 'NativeObject Get', sql: 'select * from tests where int_field=?', values: [2], results: {int_field: 2, num_field: 4.8, real_field: 5.6, text_field: 'Text2'}, use: 0},
		{name: 'NativeObject All', sql: 'select * from tests order by int_field', results: [{int_field: 1, num_field: 1.2, real_field: 2.4, text_field: 'Text1'},{int_field: 2, num_field: 4.8, real_field: 5.6, text_field: 'Text2'}], use: 1},
		{name: 'NativeObject Each', sql: 'select * from tests order by int_field', results: [{int_field: 1, num_field: 1.2, real_field: 2.4, text_field: 'Text1'},{int_field: 2, num_field: 4.8, real_field: 5.6, text_field: 'Text2'}], use: 2},

		// Promise
		{name: 'NativeObject Promise Get', sql: 'select * from tests where int_field=?', values: [2], results: {int_field: 2, num_field: 4.8, real_field: 5.6, text_field: 'Text2'}, use: 3},
		{name: 'NativeObject Promise All', sql: 'select * from tests order by int_field', results: [{int_field: 1, num_field: 1.2, real_field: 2.4, text_field: 'Text1'},{int_field: 2, num_field: 4.8, real_field: 5.6, text_field: 'Text2'}], use: 4},
		{name: 'NativeObject Promise Each', sql: 'select * from tests order by int_field', results: [{int_field: 1, num_field: 1.2, real_field: 2.4, text_field: 'Text1'},{int_field: 2, num_field: 4.8, real_field: 5.6, text_field: 'Text2'}], use: 5}

	];
	runTestGroup(tests, callback);
}
github NathanaelA / nativescript-sqlite / demo / app / main-page.js View on Github external
function runStringObjectTest(callback) {
	console.log("!--------------  Starting RSO Test");
	db.resultType(sqlite.RESULTSASOBJECT);
	db.valueType(sqlite.VALUESARENATIVE);

	const tests = [
		// Callback
		{name: 'StringObject Get', sql: 'select * from tests where int_field=?', values: [2], results: {int_field: "2", num_field: "4.8", real_field: "5.6", text_field: 'Text2'}, use: 0},
		{name: 'StringObject All', sql: 'select * from tests order by int_field', results: [{int_field: "1", num_field: "1.2", real_field: "2.4", text_field: 'Text1'},{int_field: "2", num_field: "4.8", real_field: "5.6", text_field: 'Text2'}], use: 1},
		{name: 'StringObject Each', sql: 'select * from tests order by int_field', results: [{int_field: "1", num_field: "1.2", real_field: "2.4", text_field: 'Text1'},{int_field: "2", num_field: "4.8", real_field: "5.6", text_field: 'Text2'}], use: 2},

		// Promise
		{name: 'StringObject Promise Get', sql: 'select * from tests where int_field=?', values: [2], results: {int_field: "2", num_field: "4.8", real_field: "5.6", text_field: 'Text2'}, use: 3},
		{name: 'StringObject Promise All', sql: 'select * from tests order by int_field', results: [{int_field: "1", num_field: "1.2", real_field: "2.4", text_field: 'Text1'},{int_field: "2", num_field: "4.8", real_field: "5.6", text_field: 'Text2'}], use: 4},
		{name: 'StringObject Promise Each', sql: 'select * from tests order by int_field', results: [{int_field: "1", num_field: "1.2", real_field: "2.4", text_field: 'Text1'},{int_field: "2", num_field: "4.8", real_field: "5.6", text_field: 'Text2'}], use: 5}

	];
	runTestGroup(tests, callback);
}
github Appverse / Nativescript-NG2-Showcase / app / pages / database / database.component.ts View on Github external
public setupDB() {
        this.db.resultType(Sqlite.RESULTSASOBJECT);
        this.db.execSQL('DROP TABLE IF EXISTS tests;', (err)=>{
            if (err) { console.log("!---- Drop Err", err); }
            this.db.execSQL('CREATE TABLE tests (`name` TEXT, `age` NUMERIC)', (err)=>{
                if (err) {
                    console.log("!---- Create Table err", err);
                    return;
                }
                this.db.execSQL('INSERT INTO tests (name, age) VALUES ("Nathan Drake",32)', (err, id)=>{
                    if (err) {
                        console.log("!---- Insert err", err);
                        return;
                    }
                this. db.execSQL('INSERT INTO tests (name, age) VALUES ("Elena Fisher",30)');
                });
            });
        });
github bradyhouse / house / fiddles / nativeScript / fiddle-0009-SqliteDb / puzzle / platforms / ios / puzzle / app / shared / db.service.js View on Github external
function onSelectHighScores(db, fn, scope) {
  consoleLogMsg("db.service", "onSelectHighScore");
  if (db) {
    db.resultType(Sqlite.RESULTSASOBJECT);
    db.valueType(Sqlite.VALUESARENATIVE);
    db.all(sql.selectHighScore, function (err, items) {
      data.length = 0;
      if (err) {
        console.error(err);
      } else {
        if (items && items.length) {
          items.forEach(function (item, index) {
            var record = createHighScoreRecord(item);
            consoleLogRecord(index, record);
            data.push(record);
          });
        }
        if (typeof fn === "function") {
          if (scope) {
            fn.apply(scope, [data]);
github ClickSimply / Nano-SQL / packages / Adapter-SQLite-NativeScript / src / index.ts View on Github external
this._sqlite.createAI(() => {
                this._db.resultType(NSSQLite.RESULTSASOBJECT);
                complete();
            }, error);
        });
github bradyhouse / house / fiddles / nativeScript / fiddle-0009-SqliteDb / puzzle / platforms / ios / puzzle / app / shared / db-config.service.js View on Github external
function onSelectLevel(db, fn, scope) {
  consoleLogMsg("db-config.service", "onSelectLevel");
  data.length = 0;
  if (db) {
    db.resultType(Sqlite.RESULTSASOBJECT);
    db.valueType(Sqlite.VALUESARENATIVE);
    db.all(sql.selectLevel, function (err, items) {
      if (err) {
        onDbCallback([err], fn, scope);
      } else {
        if (items && items.length) {
          items.forEach(function (item, index) {
            var record = {
              level: item.level
            };
            data.push(record);
          });
        }
        onDbCallback([data], fn, scope);
      }
    });