async_query_example.js 417 字节
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
const taos = require("td2.0-connector");
const conn = taos.connect({ host: "localhost", database: "power" });
const cursor = conn.cursor();

function queryExample() {
  cursor
    .query("SELECT ts, current FROM meters LIMIT 2")
    .execute_a()
    .then((result) => {
      result.pretty();
    });
}

try {
  queryExample();
} finally {
  setTimeout(() => {
    conn.close();
  }, 2000);
}
// bug here: jira 14506