td2.0-rest-connector
TypeScript icon, indicating that this package has built-in type declarations

1.0.7 • Public • Published

TDengine RESTful

This is a TDengine's RESTful connector in TypeScript. It's depend on node-fetch v2. Using fetch(url,options) to send sql statement and receive response.

Installation

npm i td2.0-rest-connector

Usage

import { options, connect } from 'td2.0-rest-connector'
options.path='/rest/sqlt';
// set host
options.host='localhost';
// set other options like user/passwd

let conn = connect(options);
let cursor = conn.cursor();
(async()=>{
    let result = await cursor.query('show databases');
    // print query result as taos shell
    result.toString();
    // Get Result object, return Result object.
    console.log(result.getResult());
    // Get status, return 'succ'|'error'.
    console.log(result.getStatus());
    // Get head,return response head (Array<any>|undefined,when execute failed this is undefined).
    console.log(result.getHead());
    // Get Meta data, return Meta[]|undefined(when execute failed this is undefined).
    console.log(result.getMeta());
    // Get data,return Array<Array<any>>|undefined(when execute failed this is undefined).
    console.log(result.getData());
    // Get affect rows,return number|undefined(when execute failed this is undefined).
    console.log(result.getAffectRows());
    // Get command,return SQL send to server(need to `query(sql,false)`,set 'pure=false',default true).
    console.log(result.getCommand());
    // Get error code ,return number|undefined(when execute failed this is undefined).
    console.log(result.getErrCode());
    // Get error string,return string|undefined(when execute failed this is undefined).
    console.log(result.getErrStr());
})()

Package Sidebar

Install

npm i td2.0-rest-connector

Weekly Downloads

7

Version

1.0.7

License

MIT

Unpacked Size

129 kB

Total Files

19

Last publish

Collaborators

  • tdengine