Moscrif API Docs for: 2012q3
Show:

Dataset Class

Library: sqlite

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;
}

Item Index

Methods

Properties

Methods

close

() Boolean

Close function release all resources from memory. Dataset object cannot be used longer.

Returns:

name

(
  • column
  • [witch]
)
String

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 Integer

    Number of column.

  • [witch] Symbol optional

    Symbol 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";

next

() Boolean

Advanced recordset to the next record and returns true if operation is successfull. Otherwise function returns false.

Returns:

Boolean: Returns true if operation is successfull. Otherwise function returns false.

Properties

length

Integer

Number of columns.

valid

Boolean

Reports true if the buffer contains valid row.