Skip to content
This repository was archived by the owner on Jul 7, 2022. It is now read-only.

Commit fdd2cf2

Browse files
committed
Fix for Version and ios Exec eating error
1 parent 97841a4 commit fdd2cf2

File tree

5 files changed

+56
-46
lines changed

5 files changed

+56
-46
lines changed

src/README.md

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
11
![License](https://img.shields.io/badge/license-MIT-blue.svg) ![License](https://img.shields.io/badge/platform-ios%20%7C%20android-lightgrey.svg) ![Proplugins](https://img.shields.io/badge/Pro%20plugins-Release-green.svg?logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH4wcQFCgSC/acTQAAAzxJREFUOMt91W+IVGUUBvDfnZldM90pm63cXWVaWzcMKU2WESIrCKRMUOwP5RZFwTrgtyDKov/0wTJBiimIILWwZEnqgxElGYk7qEGZabmhU+qWzZjMVGruzvTlnbgsWy9ceN/znvuc59zznHMjsZXO51QLRel8LsJkTA/PPLTiGL5CqVooji2483Ut9amQCvdnExOAXYQH8DF+xBu4D+uxNdiWwb6tq2AqnsX7uCwxDqwbd2E1bgixMvgrlshPuH7OyqeicF6PNViC3lQMbCZ2YArKOIFPA8ODgclsnI4aye8OvvNcY+GKzQ9hWgA+gANRYHgBtmExzuIlvFctFA/4j9W3/N0liaj+dhTZjXN4eWiwfygRCrAUVwXfo9g0EVit3AF2fH5z540Lvh6YfcWxcr0RzcOHQ4P9QwtXbJYI1bkW3+MkVlYLxcPpfG5CZrVyR2vf3EOvvbD6rUUPL9u+c3Q0uW1osH9jXCpd6Xyukc7njqbzuXzTXsn2iO+b7GrljjW1ckejVu5o/P7rjA/GB0zh6rDPhkI0V1sl23Mx6pnS8HHt1Mod9+MSjOFoKjn24JSBXJRMaEELMgnMiIEciu3XYQh7KtNm31T7e3qflOexIOjx1rb2kdPJhGnYgAHckcIo9obq1mKAh9EJpjQ2jA5M3uWUWmrj2VnO297WPnI4+LUGMHgsgW+RDCnPGcfwRYxJOlH/LLm0vicZ+dOrbe0ja2N+PXHRJ/Ab5mMmVsUu65nS8BPhrlekS4vWU51XroNHN/8buzcIH/YlUMEnwbAonc9dB923ZVSyPTKl4f3oD120OOvL+t3L51vbf1A6n+vF2tDfr6AUBb2txCOYFD74lmqhGC+QSrZncqY0fKaR6RZVjkjnc9nQXfOCOh7HpmbrTcU9eCb05s+4t1oo7ptI3Ol8bk7orqdxIXZiabVQrEWx4dCFLzArvHcKT6IU5PQHukNFb8cvuBTncUu1UPwhnc+Jxo2vLryJufgmVLA3BNgdRlnzvD/4flQtFI80MZJwbu/xJmhtUt+MwTAg6lgey/REYNOJXWGsbakWiiNNMIj+5xfQgstxTZDUWGB1MqR7plooNuJg8A+UzC22+9VP+QAAAABJRU5ErkJggg==) ![NativeScriptCore](https://img.shields.io/badge/Core-demo-darkblue.svg?logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH4wcQFQ4vkYI5TwAAAlhJREFUOMullU1IVFEUx3/nzvPNOBh92CAYBn1ALlyFUZRj2dDGwISIhLFttXEnIRGJmOGipSUF0SoposVAQi3EQiLEIAjSVUJhfpRULhp1xt5p8Xo+n/OGCTpweZxzz/m/e/7nnHsFoKHdMaIcROkCmoBySosAWWAU4ZZlMz76wKg0tDtGHK4Cvfyf9I0NmWuSTDv1KBOeVdVdIu4Kk2I+IrRZQJdnqIhDS0pIVMKPJXg8rKzmgmC5PJxrhn01wtxXJTMCv7IusCqdFkqT99eWlHC5zQ9ObBd6BpSKuG9bW4PGeuFQnUtjdRXcHFSiNgC1xiuAKiQqg6c5k4ILrUJ+LViK346v7q4O6LYJklPIV0c71NeFboXGmBJ4WBHo7hAvpVJ4PqCjEIv6G99/sl6Qndvg9nVBtRAhagcrbTz+Th0TTh72N95+gMFHfvSBPdB1UQpaae8uaD4ORjYBTk1r4IRlFjx9Dg+f+aCnT0DqqOu/MbP5Rfe7DmgMzMzC8MtN/Flw/wm8m/JtPR1CYoevf56DifchHBoDq/lCxvN5uHFHya74nO2v8V2WV93Y0CqHTZoIzH+DS91a9IbYXGXZGBwmkQh8/AT99zTAH4CYQjXrgS0sKsXArQgMv4IXr4P22QW/wkDOAkaBsyKQGYHqKnecpme0oGkF6B1Qtm4R4jH4sgD9dwPdMSnJtHME5Y3XPrm8O5tWBOyycAqWV9z+NhIcBqDVWDbjQJ+XZtSGeKw4GEB5zPUJgAlXxoZMZj37xrRzXpVOoBaw//EJyAGTf2/rTDLtyB9FfcLlI/KGaQAAAABJRU5ErkJggg==) [![Twitter Follow](https://img.shields.io/twitter/follow/congocart.svg?style=social&label=Follow%20me)](https://twitter.com/congocart)
22

33
# NativeScript sqlite
4-
<table><tr><td>
5-
<a href="https://proplugins.org"><img src="https://proplugins.org/logos/logo.png" width="200"/></a>
6-
</td><td>
7-
<div>Sponsored By:<br>
8-
<a href="https://master.technology"><img src="https://proplugins.org/logos/mt-banner.png" width="200"/></a></div>
9-
</td></tr></table>
10-
114

125
A NativeScript module providing sqlite actions for Android and iOS. (with multi-threading)
136

@@ -45,7 +38,7 @@ This file is REQUIRED for normal un-encrypted sqlite; but it can conflict with e
4538

4639
## Example Application
4740

48-
An example application can be downloaded form npm.proplugins.org or cloned from git.proplugins.org, in the demo folder.
41+
An example application can be downloaded or cloned from https://github.com/NathanaelA/nativescript-sqlite
4942
To use you need to do:
5043
* `npm i`
5144
* `tns run`
@@ -60,7 +53,7 @@ Then run the app the normal way you would.
6053

6154
## Installation
6255

63-
Run `tns plugin add @proplugins/nativescript-sqlite` in your ROOT directory of your project.
56+
Run `tns plugin add nativescript-sqlite` in your ROOT directory of your project.
6457

6558
***optional***
6659
* `tns plugin add ./plugins/nativescript-sqlite-commercial-???.tgz`
@@ -101,12 +94,12 @@ so that it ignores those during webpacking, right below the line that says
10194
To use the sqlite module you must first `require()` it:
10295

10396
```js
104-
const Sqlite = require( "@proplugins/nativescript-sqlite" );
97+
const Sqlite = require( "nativescript-sqlite" );
10598
```
10699

107100
(or with TypeScript, if using the commercial version)
108101
```ts
109-
import {Sqlite} from "@proplugins/nativescript-sqlite";
102+
import Sqlite from "nativescript-sqlite";
110103
```
111104

112105
After you have a reference to the module you can then call the available methods.
@@ -138,6 +131,7 @@ If you are planning on shipping a database with the application; drop the file i
138131

139132
### Methods
140133
#### new Sqlite(dbname, options, callback)
134+
#### promise = Sqlite(dbname, options, callback)
141135
##### Parameters
142136
* dbname: your database name. This can be ":memory:" for a memory Database. This can be "" for a Temporary Database.
143137
* options
@@ -151,26 +145,29 @@ If you are planning on shipping a database with the application; drop the file i
151145
You should choose either to use a promise or a callback; you can use whichever you are most comfortable with -- however, as with this example, you CAN use both if you want; but side effects WILL occur with some functions.
152146

153147
```js
154-
// my-page.js
155-
const Sqlite = require( "/path/to/node_modules/nativescript-sqlite" );
156-
const db_promise = new Sqlite("MyTable", function(err, db) {
148+
// Promise based example
149+
const Sqlite = require( "nativescript-sqlite" );
150+
151+
const db = await Sqlite("MyTable");
152+
console.log("Are we open yet (Promise based)? ", db.isOpen() ? "Yes" : "No"); // Yes
153+
```
154+
155+
or
156+
157+
```js
158+
// Callback based example
159+
const Sqlite = require( "nativescript-sqlite" );
160+
new Sqlite("MyTable", function(err, db) {
157161
if (err) {
158162
console.error("We failed to open database", err);
159163
} else {
160164
// This should ALWAYS be true, db object is open in the "Callback" if no errors occurred
161-
console.log("Are we open yet (Inside Callback)? ", db.isOpen() ? "Yes" : "No"); // Yes
165+
console.log("Are we open yet (Callback based)? ", db.isOpen() ? "Yes" : "No"); // Yes
162166
}
163167
});
164-
165-
db_promise.then(function(db) {
166-
// This should ALWAYS be true, db object is open in the "then"
167-
console.log("Are we open yet (Inside Promise)? ", db.isOpen() ? "Yes" : "No"); // Yes
168-
db.close();
169-
}, function(err) {
170-
console.error("We failed to open database", err);
171-
});
172168
```
173169

170+
174171
#### Sqlite.isSqlite()
175172
##### Parameters
176173
* object to check

src/changelog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,4 @@ v2.4.0 - Adding Sync Support
3333
v2.5.0 - NS 6 Support, Webpack fixes, iOS Fix
3434
v2.6.0 - Blog fixes, Updated typings, context fix, copyDatabase fix & can have options destination name
3535
v2.6.1 - Fixed creating :memory: table on Android. - Thanks Lars Hollenbach
36+
v2.6.2 - Doc fixes, version not returning a number when on promise based path, sqlexec eating errors on ios - Thanks Eugine Mirotin & jscti

src/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nativescript-sqlite",
3-
"version": "2.6.1",
3+
"version": "2.6.2",
44
"description": "A sqlite NativeScript module for Android and iOS",
55
"main": "sqlite",
66
"nativescript": {

src/sqlite.android.js

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*
66
* Any questions please feel free to put a issue up on github
77
* Nathan@master-technology.com http://nativescript.tools
8-
* Version 2.6.1 - Android
8+
* Version 2.6.2 - Android
99
*************************************************************************************/
1010
/* global global, require, module */
1111

@@ -371,15 +371,22 @@ Database.prototype._isSqlite = true;
371371
* @returns Promise
372372
*/
373373
Database.prototype.version = function(valueOrCallback) {
374-
if (typeof valueOrCallback === 'function') {
375-
return this.get('PRAGMA user_version', function (err, data) {
376-
valueOrCallback(err, data && parseInt(data[0],10));
377-
}, Database.RESULTSASARRAY);
378-
} else if (!isNaN(valueOrCallback+0)) {
379-
return this.execSQL('PRAGMA user_version='+(valueOrCallback+0).toString());
380-
} else {
381-
return this.get('PRAGMA user_version', undefined, undefined, Database.RESULTSASARRAY);
382-
}
374+
return new Promise((resolve, reject) => {
375+
if (typeof valueOrCallback === 'function') {
376+
this.get('PRAGMA user_version', function (err, data) {
377+
const value = data && parseInt(data[0], 10);
378+
valueOrCallback(err, value);
379+
if (err) { reject(err); }
380+
else resolve(value);
381+
}, Database.RESULTSASARRAY);
382+
} else if (!isNaN(valueOrCallback + 0)) {
383+
this.execSQL('PRAGMA user_version=' + (valueOrCallback + 0).toString()).then(resolve, reject);
384+
} else {
385+
this.get('PRAGMA user_version', undefined, undefined, Database.RESULTSASARRAY).then((data) => {
386+
resolve(data && parseInt(data[0], 10))
387+
}).catch(reject);
388+
}
389+
});
383390
};
384391

385392
/***

src/sqlite.ios.js

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*
66
* Any questions please feel free to email me or put a issue up on github
77
* Nathan@master-technology.com http://nativescript.tools
8-
* Version 2.6.0 - iOS
8+
* Version 2.6.2 - iOS
99
***********************************************************************************/
1010
/* global global, require, module */
1111

@@ -200,15 +200,22 @@ Database.prototype._isSqlite = true;
200200
* @returns Promise
201201
*/
202202
Database.prototype.version = function(valueOrCallback) {
203-
if (typeof valueOrCallback === 'function') {
204-
return this.get('PRAGMA user_version', function (err, data) {
205-
valueOrCallback(err, data && parseInt(data[0],10));
206-
}, Database.RESULTSASARRAY);
207-
} else if (!isNaN(valueOrCallback+0)) {
208-
return this.execSQL('PRAGMA user_version='+(valueOrCallback+0).toString());
209-
} else {
210-
return this.get('PRAGMA user_version', undefined, undefined, Database.RESULTSASARRAY);
211-
}
203+
return new Promise((resolve, reject) => {
204+
if (typeof valueOrCallback === 'function') {
205+
this.get('PRAGMA user_version', function (err, data) {
206+
const value = data && parseInt(data[0], 10);
207+
valueOrCallback(err, value);
208+
if (err) { reject(err); }
209+
else resolve(value);
210+
}, Database.RESULTSASARRAY);
211+
} else if (!isNaN(valueOrCallback + 0)) {
212+
this.execSQL('PRAGMA user_version=' + (valueOrCallback + 0).toString()).then(resolve, reject);
213+
} else {
214+
this.get('PRAGMA user_version', undefined, undefined, Database.RESULTSASARRAY).then((data) => {
215+
resolve(data && parseInt(data[0], 10))
216+
}).catch(reject);
217+
}
218+
});
212219
};
213220

214221
/***
@@ -410,8 +417,6 @@ Database.prototype.execSQL = function(sql, params, callback) {
410417
}
411418
resolve();
412419
}
413-
}).catch(err => {
414-
console.log("!!!", err, sql);
415420
});
416421
};
417422

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy