2.0.11
C Interface with TDengine Module
Number of fields returned in this result handle, must use with async
(any)
Asynchrnously fetches the next block of rows. Wraps callback and transfers a 4th argument to the cursor, the row data as blocks in javascript form Note: This isn't a recursive function, in order to fetch all data either use the TDengine cursor object, TaosQuery object, or implement a recrusive function yourself using the libtaos.taos_fetch_rows_a function
(any)
(any)
(any
= ref.ref(ref.NULL)
)
TAOS* taos, char* lines[], int numLines, int protocol,int precision) using taos_errstr get error info, taos_errno get error code. Remember to release taos_res, otherwise will lead memory leak. TAOS schemaless insert api
(any)
a valid database connection
(any)
string data, which satisfied with line protocol
(any)
(any)
timestamp precision in lines, enum type (0,1,2,3,4,5,6)
(any)
number of rows in param lines.
(any)
Line protocol, enum type (0,1,2,3),indicate different line protocol
any
:
TAOS_RES
init a TAOS_STMT object for later use.it should be freed with stmtClose.
(any)
valid taos connection
any
:
Not NULL returned for success, and NULL for failure.
prepare a sql statement,'sql' should be a valid INSERT/SELECT statement, 'length' is not used.
any
:
0 for success, non-zero for failure.
For INSERT only. Used to bind table name as a parmeter for the input stmt object.
(any)
could be the value returned by 'stmtInit',
that may be a valid object or NULL.
(TaosBind)
target table name you want to bind
any
:
0 for success, non-zero for failure.
For INSERT only. Set a table name for binding table name as parameter and tag values for all tag parameters.
(any)
could be the value returned by 'stmtInit', that may be a valid object or NULL.
(any)
use to set target table name
(TaosMultiBind)
use to set tag value for target table.
For INSERT only. Set a table name for binding table name as parameter. Only used for binding all tables in one stable, user application must call 'loadTableInfo' API to load all table meta before calling this API. If the table meta is not cached locally, it will return error.
(any)
could be the value returned by 'StmtInit', that may be a valid object or NULL.
(any)
table name which is belong to an stable
any
:
0 for success, non-zero for failure.
bind a whole line data, for both INSERT and SELECT. The parameter 'bind' points to an array contains the whole line data. Each item in array represents a column's value, the item number and sequence should keep consistence with columns in sql statement. The usage of structure TAOS_BIND is the same with MYSQL_BIND in MySQL.
(any)
could be the value returned by 'stmtInit', that may be a valid object or NULL.
(any)
points to an array contains the whole line data.
any
:
0 for success, non-zero for failure.
Bind a single column's data, INTERNAL used and for INSERT only.
(any)
could be the value returned by 'stmtInit', that may be a valid object or NULL.
(TaosMultiBind)
points to a column's data which could be the one or more lines.
(any)
the column's index in prepared sql statement, it starts from 0.
any
:
0 for success, non-zero for failure.
For INSERT only. Bind one or multiple lines data.
(any)
could be the value returned by 'stmtInit',
that may be a valid object or NULL.
(any)
Points to an array contains one or more lines data.The item
number and sequence should keep consistence with columns
n sql statement.
any
:
0 for success, non-zero for failure.
add all current bound parameters to batch process, for INSERT only. Must be called after each call to bindParam/bindSingleParamBatch, or all columns binds for one or more lines with bindSingleParamBatch. User application can call any bind parameter API again to bind more data lines after calling to this API.
(any)
any
:
0 for success, non-zero for failure.
actually execute the INSERT/SELECT sql statement. User application can continue to bind new data after calling to this API.
(any)
any
:
0 for success, non-zero for failure.
For SELECT only,getting the query result. User application should free it with API 'FreeResult' at the end.
(any)
could be the value returned by 'stmtInit', that may be a valid object or NULL.
any
:
Not NULL for success, NULL for failure.
user application call this API to load all tables meta info. This method must be called before stmtSetSubTbname(IntPtr stmt, string name);
(any)
taos connection
(any)
tables need to load meta info are form in an array
any
:
0 for success, non-zero for failure.
Close STMT object and free resources.
(any)
could be the value returned by 'stmtInit', that may be a valid object or NULL.
any
:
0 for success, non-zero for failure.
Get detail error message when got failure for any stmt API call. If not failure, the result returned by this API is unknown.
(any)
Could be the value returned by 'stmtInit', that may be a valid object or NULL.
any
:
error string
(Object)
Configuration options for the interface
CTaosInterface
:
Number of fields returned in this result handle, must use with async
(any)
Asynchrnously fetches the next block of rows. Wraps callback and transfers a 4th argument to the cursor, the row data as blocks in javascript form Note: This isn't a recursive function, in order to fetch all data either use the TDengine cursor object, TaosQuery object, or implement a recrusive function yourself using the libtaos.taos_fetch_rows_a function
(any)
(any)
(any
= ref.ref(ref.NULL)
)
TAOS* taos, char* lines[], int numLines, int protocol,int precision) using taos_errstr get error info, taos_errno get error code. Remember to release taos_res, otherwise will lead memory leak. TAOS schemaless insert api
(any)
a valid database connection
(any)
string data, which satisfied with line protocol
(any)
(any)
timestamp precision in lines, enum type (0,1,2,3,4,5,6)
(any)
number of rows in param lines.
(any)
Line protocol, enum type (0,1,2,3),indicate different line protocol
any
:
TAOS_RES
init a TAOS_STMT object for later use.it should be freed with stmtClose.
(any)
valid taos connection
any
:
Not NULL returned for success, and NULL for failure.
prepare a sql statement,'sql' should be a valid INSERT/SELECT statement, 'length' is not used.
any
:
0 for success, non-zero for failure.
For INSERT only. Used to bind table name as a parmeter for the input stmt object.
(any)
could be the value returned by 'stmtInit',
that may be a valid object or NULL.
(TaosBind)
target table name you want to bind
any
:
0 for success, non-zero for failure.
For INSERT only. Set a table name for binding table name as parameter and tag values for all tag parameters.
(any)
could be the value returned by 'stmtInit', that may be a valid object or NULL.
(any)
use to set target table name
(TaosMultiBind)
use to set tag value for target table.
For INSERT only. Set a table name for binding table name as parameter. Only used for binding all tables in one stable, user application must call 'loadTableInfo' API to load all table meta before calling this API. If the table meta is not cached locally, it will return error.
(any)
could be the value returned by 'StmtInit', that may be a valid object or NULL.
(any)
table name which is belong to an stable
any
:
0 for success, non-zero for failure.
bind a whole line data, for both INSERT and SELECT. The parameter 'bind' points to an array contains the whole line data. Each item in array represents a column's value, the item number and sequence should keep consistence with columns in sql statement. The usage of structure TAOS_BIND is the same with MYSQL_BIND in MySQL.
(any)
could be the value returned by 'stmtInit', that may be a valid object or NULL.
(any)
points to an array contains the whole line data.
any
:
0 for success, non-zero for failure.
Bind a single column's data, INTERNAL used and for INSERT only.
(any)
could be the value returned by 'stmtInit', that may be a valid object or NULL.
(TaosMultiBind)
points to a column's data which could be the one or more lines.
(any)
the column's index in prepared sql statement, it starts from 0.
any
:
0 for success, non-zero for failure.
For INSERT only. Bind one or multiple lines data.
(any)
could be the value returned by 'stmtInit',
that may be a valid object or NULL.
(any)
Points to an array contains one or more lines data.The item
number and sequence should keep consistence with columns
n sql statement.
any
:
0 for success, non-zero for failure.
add all current bound parameters to batch process, for INSERT only. Must be called after each call to bindParam/bindSingleParamBatch, or all columns binds for one or more lines with bindSingleParamBatch. User application can call any bind parameter API again to bind more data lines after calling to this API.
(any)
any
:
0 for success, non-zero for failure.
actually execute the INSERT/SELECT sql statement. User application can continue to bind new data after calling to this API.
(any)
any
:
0 for success, non-zero for failure.
For SELECT only,getting the query result. User application should free it with API 'FreeResult' at the end.
(any)
could be the value returned by 'stmtInit', that may be a valid object or NULL.
any
:
Not NULL for success, NULL for failure.
user application call this API to load all tables meta info. This method must be called before stmtSetSubTbname(IntPtr stmt, string name);
(any)
taos connection
(any)
tables need to load meta info are form in an array
any
:
0 for success, non-zero for failure.
Close STMT object and free resources.
(any)
could be the value returned by 'stmtInit', that may be a valid object or NULL.
any
:
0 for success, non-zero for failure.
Get detail error message when got failure for any stmt API call. If not failure, the result returned by this API is unknown.
(any)
Could be the value returned by 'stmtInit', that may be a valid object or NULL.
any
:
error string
TDengine Connection Class
(object)
Options for configuring the connection with TDengine
TDengineConnection
:
//Initialize a new connection
var conn = new TDengineConnection({host:"127.0.0.1", user:"root", password:"taosdata", config:"/etc/taos",port:0})
Close the connection to TDengine
Initialize a new cursor to interact with TDengine with
TDengineCursor
:
(number)
The code to get the name of the type for
string
:
Name of the field type
Contains the the definitions/values assigned to various field types
(TDengineConnection)
The TDengine Connection this cursor uses to interact with TDengine
(data)
: Latest retrieved data from query execution. It is an empty array by default
(fields)
: Array of the field objects in order from left to right of the latest data retrieved
Create a TaosQuery object to perform a query to TDengine and retrieve data.
(string)
The operation string to perform a query on
(boolean
= false
)
Whether or not to immedietely perform the query. Default is false.
(TaosQuery | Promise<TaosResult>)
:
A TaosQuery object
var query = cursor.query("select count(*) from meterinfo.meters");
query.execute();
Execute a query. Also stores all the field meta data returned from the query into cursor.fields. It is preferable to use cursor.query() to create queries and execute them instead of using the cursor object directly.
(string)
The query operation to execute in the taos shell
(Object)
Execution options object. quiet : true turns off logging from queries
Name | Description |
---|---|
options.quiet boolean
|
True if you want to surpress logging such as "Query OK, 1 row(s) ..." |
(function)
A callback function to execute after the query is made to TDengine
(number | Buffer)
:
Number of affected rows or a Buffer that points to the results of the query
Fetches all results from a query and also stores results into cursor.data. It is preferable to use cursor.query() to create queries and execute them instead of using the cursor object directly.
(any)
(function)
callback function executing on the complete fetched data
Array<Array>
:
The resultant array, with entries corresponding to each retreived row from the query results, sorted in
order by the field name ordering in the table.
cursor.execute('select * from db.table');
var data = cursor.fetchall(function(results) {
results.forEach(row => console.log(row));
})
Asynchrnously execute a query to TDengine. NOTE, insertion requests must be done in sync if on the same table.
(string)
The query operation to execute in the taos shell
(Object)
Execution options object. quiet : true turns off logging from queries
Name | Description |
---|---|
options.quiet boolean
|
True if you want to surpress logging such as "Query OK, 1 row(s) ..." |
(function)
A callback function to execute after the query is made to TDengine
(any)
(number | Buffer)
:
Number of affected rows or a Buffer that points to the results of the query
Fetches all results from an async query. It is preferable to use cursor.query_a() to create async queries and execute them instead of using the cursor object directly.
(any)
(Object)
An options object containing options for this function
(function)
callback function that is callbacked on the COMPLETE fetched data (it is calledback only once!).
Must be of form function (param, result, rowCount, rowData)
(Object
= {}
)
A parameter that is also passed to the main callback function. Important! Param must be an object, and the key "data" cannot be used
{param: Object, result: Buffer}
:
An object with the passed parameters object and the buffer instance that is a pointer to the result handle.
cursor.execute('select * from db.table');
var data = cursor.fetchall(function(results) {
results.forEach(row => console.log(row));
})
Subscribe to a table from a database in TDengine.
(Object)
A configuration object containing the configuration options for the subscription
Name | Description |
---|---|
config.restart string
|
whether or not to continue a subscription if it already exits, otherwise start from beginning |
config.topic string
|
The unique identifier of a subscription |
config.sql string
|
A sql statement for data query |
config.interval string
|
The pulling interval |
Buffer
:
A buffer pointing to the subscription session handle
An infinite loop that consumes the latest data and calls a callback function that is provided.
schemaless insert
(any)
string data, which statisfied with line proctocol
(any)
(any)
timestamp precision in lines, enum type (0,1,2,3,4,5,6)
(any)
a valid database connection
(any)
Line protocol, enum type (0,1,2,3),indicate different line protocol
any
:
TAOS_RES
init a TAOS_STMT object for later use.it should be freed with stmtClose.
any
:
Not NULL returned for success, and NULL for failure.
For INSERT only. Used to bind table name as a parmeter for the input stmt object.
(TaosBind)
target table name you want to bind
any
:
0 for success, non-zero for failure.
For INSERT only. Set a table name for binding table name as parameter and tag values for all tag parameters.
(any)
use to set target table name
(TaosMultiBind)
use to set tag value for target table.
For INSERT only. Set a table name for binding table name as parameter. Only used for binding all tables in one stable, user application must call 'loadTableInfo' API to load all table meta before calling this API. If the table meta is not cached locally, it will return error.
(any)
table name which is belong to an stable
any
:
0 for success, non-zero for failure.
bind a whole line data, for both INSERT and SELECT. The parameter 'bind' points to an array contains the whole line data. Each item in array represents a column's value, the item number and sequence should keep consistence with columns in sql statement. The usage of structure TAOS_BIND is the same with MYSQL_BIND in MySQL.
(any)
points to an array contains the whole line data.
any
:
0 for success, non-zero for failure.
Bind a single column's data, INTERNAL used and for INSERT only.
(TaosMultiBind)
points to a column's data which could be the one or more lines.
(any)
the column's index in prepared sql statement, it starts from 0.
any
:
0 for success, non-zero for failure.
For INSERT only. Bind one or multiple lines data.
(any)
Points to an array contains one or more lines data.The item
number and sequence should keep consistence with columns
n sql statement.
any
:
0 for success, non-zero for failure.
add all current bound parameters to batch process, for INSERT only. Must be called after each call to bindParam/bindSingleParamBatch, or all columns binds for one or more lines with bindSingleParamBatch. User application can call any bind parameter API again to bind more data lines after calling to this API.
(any)
any
:
0 for success, non-zero for failure.
actually execute the INSERT/SELECT sql statement. User application can continue to bind new data after calling to this API.
(any)
any
:
0 for success, non-zero for failure.
For SELECT only,getting the query result. User application should free it with API 'FreeResult' at the end.
any
:
Not NULL for success, NULL for failure.
user application call this API to load all tables meta info. This method must be called before stmtSetSubTbname(IntPtr stmt, string name);
(any)
tables need to load meta info are form in an array
any
:
0 for success, non-zero for failure.
close STMT object and free resources.
(any)
any
:
0 for success, non-zero for failure.
Used to bind null value for all data types that tdengine supports.
(bool)
is not null bool value,true or false.
(int8)
is a not null tinyint value.
(short)
is a not null small int value.
(int)
is a not null int value.
(long)
is not null big int value.
(float)
is a not null float value
(double)
is a not null double value
(string)
is a string.
(long)
is a not null timestamp(long) values.
(string)
is a string.
(uint8)
is a not null unsinged tinyint value.
(uint16)
is a not null unsinged smallint value.
(uint32)
is a not null unsinged int value.
(uint64)
is a not null unsinged bigint value.
(jsonStr)
is a json string. Such as '{"key1":"taosdata"}'
any
:
binded buffer.
To bind bool through an array.
(any)
is an boolean array that stores one column's value.
any
:
A instance of struct TAOS_MULTI_BIND that contains one column's data with bool type.
to bind tiny int through an array.
(any)
is an array that stores tiny int.
any
:
A instance of struct TAOS_MULTI_BIND that contains one column's data with tiny int.
To bind small int through an array.
(any)
is an array that stores small int.
any
:
A instance of struct TAOS_MULTI_BIND that contains one column's data with small int.
To bind int through an array.
(any)
is an array that stores int.
any
:
A instance of struct TAOS_MULTI_BIND that contains one column's data with int.
To bind big int through an array.
(any)
is an array that stores big int.
any
:
A instance of struct TAOS_MULTI_BIND that contains one column's data with big int.
To bind float through an array.
(any)
is an array that stores float.
any
:
A instance of struct TAOS_MULTI_BIND that contains one column's data with float.
To bind double through an array.
(any)
is an array that stores double.
any
:
A instance of struct TAOS_MULTI_BIND that contains one column's data with double.
To bind tdengine's binary through an array.
(any)
is an array that stores string.
(Null string can be defined as undefined or null,notice '' is not null.)
any
:
A instance of struct TAOS_MULTI_BIND that contains one column's data with binary.
To bind timestamp through an array.
(any)
is an array that stores timestamp.
any
:
A instance of struct TAOS_MULTI_BIND that contains one column's data with timestamp.
To bind tdengine's nchar through an array.
(any)
is an array that stores string.
(Null string can be defined as undefined or null,notice '' is not null.)
any
:
A instance of struct TAOS_MULTI_BIND that contains one nchar column's data with nchar.
to bind unsigned tiny int through an array.
(any)
is an array that stores unsigned tiny int.
any
:
A instance of struct TAOS_MULTI_BIND that contains one column's data with unsigned tiny int.
To bind unsigned small int through an array.
(any)
is an array that stores unsigned small int.
any
:
A instance of struct TAOS_MULTI_BIND that contains one column's data with unsigned small int.
To bind unsigned int through an array.
(any)
is an array that stores unsigned int.
any
:
A instance of struct TAOS_MULTI_BIND that contains one column's data with unsigned int.
To bind unsigned big int through an array.
(any)
is an array that stores unsigned big int.
any
:
A instance of struct TAOS_MULTI_BIND that contains one column's data with unsigned big int.
(any)
an string array
any
:
return the max length of the element in strArr in "UFT-8" encoding.
(any)
a string.
any
:
return the length of the input string encoding with utf-8.
The constructor,initial basic parameters and alloc buffer.
(any)
the number of column that you want to bind parameters.
Used to bind boolean column's values.
(any)
An array of bool value,
represents the bool values you want to bind.
Used to bind tiny int column's values.
(any)
An array of tiny int value.
represents the tiny int values you want to bind.
Used to bind small int column's value.
(any)
An array of small int values,
represents the small int values you want to bind.
Used to bind int column's value.
(any)
An array of int values,
represents the int values you want to bind.
Used to bind big int column's value.
(any)
An array of big int values,
represents the big int values you want to bind.
Used to bind float column's value.
(any)
An array of float values,
represents the float values you want to bind.
Used to bind double column's value.
(any)
An array of double values,
represents the double values you want to bind.
Used to bind binary column's value.
(any)
An array of binary(string) values,
represents the binary values you want to bind.
Notice '' is not equal to TDengine's "null" value.
Used to bind timestamp column's values.
(any)
An array of timestamp values,
represents the timestamp values you want to bind.
Used to bind nchar column's value.
(any)
An array of nchar(string) values,
represents the nchar values you want to bind.
Notice '' is not equal to TDengine's "null" value.
Used to bind unsigned tiny int column's value.
(any)
An array of unsigned tiny int values,
represents the unsigned tiny int values you want to bind.
Used to bind unsigned small int column's value.
(any)
An array of unsigned small int value,
represents the unsigned small int values you want to bind.
Used to bind unsigned int column's value.
(any)
An array of unsigned int column's value,
represents the unsigned int values you want to bind.
Used to bind unsigned big int column's value.
(any)
An array of unsigned big int column's value,
represents the unsigned big int values you want to bind.
After all the parameters have been prepared and stored in the buffer, Call this method to get the buffer.
any
:
return the buffer which stores all the parameters.
TDengine raw timestamp.
any
:
raw taos timestamp (int64)
Gets the microseconds of a Date.
Int
:
A microseconds integer
Gets the nanoseconds of a TaosTimestamp.
Int
:
A nanoseconds integer
String
:
a string for timestamp string format
string
:
A Taos Timestamp String
Custom console.log
(any)
(any)
String
:
string format for debug
Various objects such as TaosRow and TaosColumn that help make parsing data easier
(string)
Query to construct object from
(TDengineCursor)
The cursor from which this query will execute from
(boolean)
Whether or not to immedietely execute the query synchronously and fetch all results. Default is false.
(string)
: The current query in string format the TaosQuery object represents
TaosQuery
:
Executes the query object and returns a Promise
Promise<TaosResult>
:
A promise that resolves with a TaosResult object, or rejects with an error
Executes the query object asynchronously and returns a Promise. Completes query to completion.
(Object
= {}
)
Execution options
Promise<TaosResult>
:
A promise that resolves with a TaosResult object, or rejects with an error
Bind arguments to the query and automatically parses them into the right format
(any)
(...any)
TaosQuery
:
// An example of binding a javascript date and a number to a query
var query = cursor.query("select count(*) from meterinfo.meters where ts <= ? and areaid = ?").bind(new Date(), 3);
var promise1 = query.execute();
promise1.then(function(result) {
result.pretty(); // Log the prettified version of the results.
});
(Array<TaosRow>)
: Array of TaosRows forming the result data (this does not include field meta data)
(Array<TaosField>)
: Array of TaosFields forming the fields meta data array.
TaosResult
:
Pretty print data and the fields meta data as if you were using the taos shell