TDengine/docs/examples/node/insert.js

23 lines
478 B
JavaScript
Raw Permalink Normal View History

2024-11-15 09:26:42 +00:00
const taos = require('@tdengine/websocket');
2022-06-18 10:07:47 +00:00
2024-11-15 09:26:42 +00:00
var url = process.env.TDENGINE_CLOUD_URL;
2024-11-22 03:22:21 +00:00
async function insertData() {
2024-11-15 09:26:42 +00:00
let conn = null;
2022-06-18 10:07:47 +00:00
try {
2024-11-15 09:26:42 +00:00
let conf = new taos.WSConfig(url);
conf.setDb('test');
conn = await taos.sqlConnect(conf);
2024-11-15 10:04:16 +00:00
await conn.exec(
"insert into cloud using meters tags (1, 'new york') values (now, 1.1, 1, 1.1)"
);
2022-06-18 10:07:47 +00:00
} catch (err) {
2024-11-15 09:26:42 +00:00
throw err;
} finally {
if (conn) {
await conn.close();
}
2022-06-18 10:07:47 +00:00
}
}
2024-11-22 03:22:21 +00:00
insertData();