Delphi programming language is used in the class TDataSet. TDataSet class is the main class which controls all database operations. This class can be used with node.js so I wrote with JavaScript. Firebird support is available now.
Some of the advantages;
from the SELECT query, update and insert queries are automatically generated.
"Key Field" and "master table" in the query is parsed automatically.
According to the type of field value assignments and readings are performed.
Please report any errors in the opinions and requests.
npm install tdataset
var db = require("tdataset");
var Db = new db.TServerConnection();
Db.DBName = "test";
Db.DBPort = "3050";
Db.DBUserName = "SYSDBA";
Db.DBServer = "localhost";
Db.DBPassword = "masterkey";
var Connection;
function returnQuery() {
var Dst = new db.TServerDataSet();
Dst.Params = undefined;
Dst.Connection = Connection;
Dst.SelectSQL = "SELECT * FROM CUSTOMERS";
Dst.KeyFieldName = "ID";
Dst.Open(false, 0, 0, function(Result, Err) {
if (Result) {
console.log("record count:"+Dst.RecordCount);
console.log("field count:"+Dst.FieldsCount);
console.log(Dst.Fields("ID").AsString);
console.log(Dst.Fields(0).AsString);
Dst.Edit();
Dst.Fields("NAME").AsString = "Test";
Dst.Post(function(Result, Err) {
console.log("post complete.");
Dst.Append(function(Result) {
Dst.Fields("NAME").AsString = "Test Append";
Dst.Post(function(Result, Err) {
console.log("append complete");
});
});
});
}
});
}
Db.Connect(function(Status, Db) {
if (Status) {
Connection = Db;
returnQuery();
}
else console.log(Db);
});
class represent Delphi TField class.
this method return field value or set field value.
Returns: *, this method return field value or set field value.
this method return field value as string or set value from string.
Returns: string, this method return field value as string or set value from string.
this method return field value as integer or set value from integer.
Returns: integer, this method return field value as integer or set value from integer.
this method return field value as date or set value from date.
Returns: date, this method return field value as date or set value from date.
represent from Delphi TDataSet
if focused record is last record this method return true.
Returns: boolean, if focused record is last record this method return true.
if focused record is first record this method return true.
Returns: boolean, if focused record is first record this method return true.
this method get dataset rows.
Returns: TList, this method get dataset rows.
this method return focused record number.
Returns: integer, this method return focused record number.
this method return record count.
Returns: integer, this method return record count.
this method return field count.
Returns: integer, this method return field count.
this method return TField passed field name or number. Example: TDataSet.Fields("ADI").AsString
Parameters
Field: integer | string, number or Field name.
Returns: {TField]
this method focused first record in dataset.
this method focused next record in dataset.
this method focused prior record in dataset.
this method cancel any changes in dataset. this method only run edit or insert mode.
this method setting dataset mode to Editing
this method search value in key field param.
Parameters
KeyField: string, name
Value: *, this method search value in key field param.
Returns: boolean, this method search value in key field param.
this method close dataset and free dataset memory.
TServerConnection class. Main DB Connection class.
Database connection method.
Parameters
OnResult: callback, connectionCallBack
This method add a new record in dataset.
Parameters
OnResult: callBack, nothing return any param.
this method delete focused record in database.
Parameters
OnSuccess: callback, this callback return Result and Err params. Result params boolean, Err params string return value.
this method save record to database. this method only calling dataset mode editing or inserting.
Parameters
OnSuccess: callback, return Result boolean param and Err string param.
this method onyl execute sql not return field or value. Example UPDATA T SET A = 1
Parameters
SQL: string, this method onyl execute sql not return field or value. Example UPDATA T SET A = 1
OnExecute: callback, this method onyl execute sql not return field or value. Example UPDATA T SET A = 1
This method open dataset and dataset mode setting browsing.
Parameters
Fetch: boolean, this param using fetching limit (limit sql command) setting the true.
Skip: integer, skip record size.
First: integer, first record size.
OnConnect: callback, global return callback.
The MIT License (MIT)
Copyright (c) 2014 Serkan KOCAMAN newkipsoftware@gmail.com
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Serkan KOCAMAN
Overview: Delphi TDataset represent for node.js
Version: 0.0.1