1
- var sqlite = require ( 'nativescript-sqlite' ) ;
2
- var ObservableArray = require ( "data/observable-array" ) . ObservableArray ;
1
+ const sqlite = require ( 'nativescript-sqlite' ) ;
2
+ const ObservableArray = require ( "tns-core-modules/ data/observable-array" ) . ObservableArray ;
3
3
4
4
5
5
//var Tracing = require('./tracing.js');
@@ -22,14 +22,21 @@ if (sqlite.HAS_COMMERCIAL) {
22
22
23
23
if ( sqlite . HAS_ENCRYPTION ) {
24
24
console . log ( "Using Encryption" ) ;
25
- dbname = 'encrypted.sqlite' ;
25
+ // dbname = 'encrypted.sqlite';
26
26
data . push ( { name :'Encryption Support' , css :'one' } ) ;
27
27
} else {
28
28
console . log ( "No Encryption" ) ;
29
29
}
30
30
data . push ( { name : 'Loading...' , css : 'one' } ) ;
31
31
32
32
33
+ if ( sqlite . HAS_SYNC ) {
34
+ console . log ( "Using Sync" ) ;
35
+ data . push ( { name : 'Sync Support' , css : 'one' } ) ;
36
+ } else {
37
+ console . log ( "No Sync" ) ;
38
+ }
39
+
33
40
34
41
exports . pageLoaded = function ( args ) {
35
42
page = args . object ;
@@ -38,7 +45,7 @@ exports.pageLoaded = function(args) {
38
45
if ( ! sqlite . exists ( dbname ) ) {
39
46
sqlite . copyDatabase ( dbname ) ;
40
47
}
41
- new sqlite ( dbname , { key : 'testing' , multithreading : ! ! sqlite . HAS_COMMERCIAL , migrate : true } , function ( err , dbConnection ) {
48
+ new sqlite ( dbname , { zkey : 'testing' , multithreading : false /* !!sqlite.HAS_COMMERCIAL */ , migrate : true } , function ( err , dbConnection ) {
42
49
if ( err ) {
43
50
console . log ( err , err . stack ) ;
44
51
}
@@ -62,22 +69,59 @@ exports.pageLoaded = function(args) {
62
69
} ;
63
70
64
71
exports . addNewName = function ( ) {
65
- var entry = page . getViewById ( 'entry' ) ;
66
- var name = entry . text ;
72
+ const entry = page . getViewById ( 'entry' ) ;
73
+ const name = entry . text ;
67
74
if ( name . length > 0 ) {
68
75
if ( name . toLowerCase ( ) === "test" || name . toLowerCase ( ) === "runtest" || name . toLowerCase ( ) === "tests" || name . toLowerCase ( ) === "runtests" || name . indexOf ( "Test" ) === 0 ) {
69
76
runTests ( ) ;
70
77
return ;
71
78
}
72
79
80
+ if ( name . toLowerCase ( ) === "sync" ) {
81
+ db . enableTracking ( "names" , { 'syncTime' : 10 } ) . then ( ( res ) => {
82
+ console . log ( "Result" , res ) ;
83
+ } ) . catch ( ( err ) => {
84
+ console . log ( "Error" , err , err . stack ) ;
85
+ } ) ;
86
+ return ;
87
+ }
88
+
89
+ if ( name . toLowerCase ( ) === "fsync" ) {
90
+ db . enableTracking ( "names" , { force : true , syncTime : 10 } ) . then ( ( res ) => {
91
+ console . log ( "Result" , res ) ;
92
+ } ) . catch ( ( err ) => {
93
+ console . log ( "Error" , err , err . stack ) ;
94
+ } ) ;
95
+ return ;
96
+ }
97
+
98
+ if ( name . toLowerCase ( ) === "csync" ) {
99
+ db . execSQL ( "update __mt_sync_tracking set completed=1" ) ;
100
+ return ;
101
+ }
102
+
103
+
104
+ if ( name . toLowerCase ( ) === "dsync" ) {
105
+ db . execSQL ( "delete from __mt_sync_tracking" ) ;
106
+ return ;
107
+ }
108
+
109
+ if ( name . toLowerCase ( ) === 'tsync' ) {
110
+ db . all ( "select * from __mt_sync_tracking" ) . then ( ( res ) => {
111
+ console . log ( "Results:" , res ) ;
112
+ } ) ;
113
+ return ;
114
+ }
115
+
116
+
73
117
db . execSQL ( "insert into names (name) values (?)" , name ) ;
74
118
reloadData ( ) ;
75
119
}
76
120
entry . text = '' ;
77
121
} ;
78
122
79
123
exports . openMT = function ( ) {
80
- const utils = require ( 'utils/utils' ) ;
124
+ const utils = require ( 'tns-core-modules/ utils/utils' ) ;
81
125
utils . openUrl ( "https://www.master-technology.com" ) ;
82
126
} ;
83
127
@@ -410,7 +454,19 @@ function setupPreparedTests(callback) {
410
454
callback ( ) ;
411
455
return ;
412
456
}
413
- console . log ( "!--------- Creating Prepared Tests Data" ) ;
457
+
458
+ console . log ( "!--------- Creating Prepared Tests Data" ) ;
459
+ db . execSQL ( [ 'drop table if exists preparetests;' , 'create table preparetests (`int_field` integer, `num_field` numeric, `real_field` real, `text_field` text)' ] , function ( err ) {
460
+ if ( err ) {
461
+ data . push ( { name : 'Failed to create tables and data...' , css : 'one' } ) ;
462
+ console . log ( "!---- Create Table err" , err ) ;
463
+ return ;
464
+ }
465
+ callback ( ) ;
466
+ } ) ;
467
+
468
+
469
+ /*
414
470
db.execSQL('drop table if exists preparetests;', function (err) {
415
471
if (err) {
416
472
console.log("!---- Drop Err", err);
@@ -423,7 +479,7 @@ function setupPreparedTests(callback) {
423
479
}
424
480
callback();
425
481
});
426
- } ) ;
482
+ }); */
427
483
}
428
484
429
485
function runPreparedTests ( callback ) {
@@ -437,7 +493,7 @@ function runPreparedTests(callback) {
437
493
setupPreparedTests ( function ( ) {
438
494
createPreparedData ( true , function ( ) {
439
495
440
- var tests = [ {
496
+ let tests = [ {
441
497
name : 'Verify Rollback Check' ,
442
498
sql : 'select count(*) from preparetests' ,
443
499
results : [ 0 ] ,
0 commit comments