Dataset Class
This class allows manipulate with data returns by SQLite database. This object can be create only by exec function from Database class.
Example:
// Returns object constructed from current row as { field1: value1, field2: value2, etc. }
function Dataset.rowAsObject()
{
var names = this.names;
if (!names) {
names = [];
for (var n = 0; n < this.length; ++n)
names.push(symbol(this.name(n)));
this.names = names;
}
var obj = {}; var n = 0;
for (var v in this)
obj[names[n++]] = v;
return obj;
}
Methods
close
() Boolean
Close function release all resources from memory. Dataset object cannot be used longer.
Returns:
name
(
String
column
[witch]
This call returns name of column set by integer (first column is 0, second 1 etc) or thanks to second parameter function can return also name of table or databse.
Parameters:
-
column
IntegerNumber of column.
-
[witch]
Symbol optionalSymbol that specifies which name should be returned. Implicitly function return name of column. * #logical - function returns name of column * #field - function returns name of column * #table - function returns name of table * #database - function returns name of database
Returns:
String: Name offset column, table orientation database.
Example:
//Select all data from db table in database
var result = database.exec("SELECT * FROM db;");
//name of first column
console<<result.name(0)<<"\n";
//name of second column
console<<result.name(1)<<"\n";
//name of table
console<<result.name(1, #table)<<"\n";
//name of database
console<<result.name(1, #database)<<"\n";