Bro, sorry my english, because this time I use Google Translate.
I'm trying to recover data from SQLite, the Object Format (db.resultType (sqlite.RESULTSASOBJECT)). In android works perfectly, but already in the iOS does not work well.
Problems encountered:
1 - file: /// app (nativescript-sqlite-example) /main-page.js:38:24: CONSOLE LOG TypeError: colName.contains is not a function. (In 'colName.contains (cn)', 'colName.contains' is undefined)
1.1 - Fixed: I added the end of the script (sqlite.ios.js), the following code:
// HERE JS
if ( !Array.prototype.contains ) {
Object.defineProperty(Array.prototype, 'contains', {
enumerable: false,
configurable: true,
writable: true,
value: function(searchElement/, fromIndex/) {
if (this === undefined || this === null) {
throw new TypeError('Cannot convert this value to object');
}
var O = Object(this);
var len = parseInt(O.length) || 0;
if (len === 0) { return false; }
var n = parseInt(arguments[1]) || 0;
if (n >= len) { return false; }
var k;
if (n >= 0) {
k = n;
} else {
k = len + n;
if (k < 0) k = 0;
}
while (k < len) {
var currentElement = O[k];
if (searchElement === currentElement ||
searchElement !== searchElement && currentElement !== currentElement
) {
return true;
}
k++;
}
return false;
}
});
}
2 - Method (_getResults) var cn = sqlite3_column_name (statement, i) .value; This not returning the column name, but the "index".
file: ///app/tns_modules/nativescript-sqlite/sqlite.js: 575: 28: CONSOLE LOG CN: 110
-- I tried to solve using other commands as sqlite3_column_origin_name, but not succeeded yet.
3 - Method (_getResult):
3.1 - I am having problem trying to retrieve a column of type text.
Note: 110 its a column "name", returned from sqlite3_column_name (statement, i) .value; the rest is "value"(text).
110: NSString {boundingRectWithSizeOptionsAttributesContext: function, cString: function, cStringLength: function, cStringUsingEncoding: function, canBeConvertedToEncoding: function, …}
3.2 - The int and float types are being returned as String, I just realized the parseInt or parseFloat, and went on to correctly return type.
I am using OSX 10.10.5, Xcode 6.4 SDK (8.4), 1.4.2 and NativeScript NativeScript-sqlite 1.0.0.
Note: I tried to https://github.com/NathanaelA/nativescript-sqlite-example, which uses NativeScript-sqlite 1.0.1 and had the same problem with iOS.
Am new development with NativeScript and javascript, I am striving to tackle this problem and help the community, please give me tips to help you and solve such problems.
For I am developing an application for company in which work and need to solve such "bugs"
In Android works fine !