Sqlite database result type as object instead of default array


#1

Hey all!

In some situation we may required result type as object instead of array while querying into local database using awesome nativescript-sqlite.

So we may change the result type by passing the resultType as below mentioned,

var Sqlite = require(‘nativescriipt-sqlite’);

 
var db_promise = new Sqlite("MyTable").then(function(db) {
        db.resultType(Sqlite.RESULTSASOBJECT);

         

      console.log("Are we open yet (Inside Promise)? ", db.isOpen() ? "Yes" : "No"); // Yes

      db.close();

   }, function(err) {

     console.error("We failed to open database", err);

   });

Thanks to @NathanaelA & @nraboy.

Hope this may help someone.