fix node.js example error (#30287)

* test: node example case

* fix: node.js example error

* fix: restore test case validation
This commit is contained in:
kevin men 2025-03-19 22:38:54 +08:00 committed by GitHub
parent eaf87a5adb
commit b46d79a36c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 2 deletions

View File

@ -1,4 +1,3 @@
const { sleep } = require("@tdengine/websocket");
const taos = require("@tdengine/websocket");
// ANCHOR: create_consumer
@ -52,6 +51,12 @@ async function prepare() {
await wsSql.close();
}
const delay = function(ms) {
return new Promise(function(resolve) {
setTimeout(resolve, ms);
});
};
async function insert() {
let conf = new taos.WSConfig('ws://localhost:6041');
conf.setUser('root');
@ -60,7 +65,7 @@ async function insert() {
let wsSql = await taos.sqlConnect(conf);
for (let i = 0; i < 50; i++) {
await wsSql.exec(`INSERT INTO d1001 USING ${stable} (location, groupId) TAGS ("California.SanFrancisco", 3) VALUES (NOW, ${10 + i}, ${200 + i}, ${0.32 + i})`);
await sleep(100);
await delay(100);
}
await wsSql.close();
}