DatabaseSync

DatabaseSync

Provides access to databases via the WebSQLDatabase API. Only the synchronous part of the API is implemented because asynchronous code is usually not required for server-side scripting.

Example:

// open a SQL Server CE database (path is in virtual file-system)
var db = new DatabaseSync("/Databases/mydatabase.sdf");   
db.readTransaction(function(tx) {
  var result = tx.executeSql("SELECT Name FROM Company");
  for (var i in result.rows) {
    var row = result.rows[i];
    console.log(row.Name);
  }
});

Constructor

new DatabaseSync(connectionString)

Description:
  • Opens a connection to the database with the given connection-string. The connectionString must be either the virtual file-system path of an SQLite or SQL Server Compact file, or a prefixed database connection-string. The prefixes are shown below:

    Connection-type Prefix File-extension Database DLLs required?
    SQLite sqlite:* .sqlite3 no
    SQL Server Compact sqlserverce:* .sdf no
    SQL Server sqlserver: n/a no
    ODBC odbc: n/a no
    OLE DB oledb: n/a yes**

    * - Prefixes are only required for SQLite and SQL Server Compact if the listed file-extension isn't being used.

    ** - For OLE DB connections the DLLs for the specific database being accessed must be placed in the same directory as the CompleteFTP server executables.

Source:
Parameters:
Name Type Description
connectionString String

Members

lastRowIdQuery :String

Description:
  • SQL statement used to obtain the ID of the most recently inserted row.

Source:

SQL statement used to obtain the ID of the most recently inserted row.

Type:
  • String

Methods

changeVersion()

Description:
  • Not implemented.

Source:

readTransaction(callbackopt)

Description:
  • Run the read transaction contained in the given callback function. A SQLTransactionSync object is passed as an argument to the callback. This may be used execute queries. The transaction is committed if the callback returns normally and rolled back if it throws an exception.

Source:
Parameters:
Name Type Attributes Description
callback function <optional>

callback function

Properties
Name Type Attributes Description
transaction SQLTransactionSync <optional>

Transaction object which can be used to execute SQL queries.

transaction(callbackopt)

Description:
  • Run the non-read transaction contained in the given callback function. A SQLTransactionSync object is passed as an argument to the callback. This may be used execute queries. The transaction is committed if the callback returns normally and rolled back if it throws an exception.

Source:
Parameters:
Name Type Attributes Description
callback function <optional>

callback function

Properties
Name Type Attributes Description
transaction SQLTransactionSync <optional>

Transaction object which can be used to execute SQL queries.