modify node ci example

This commit is contained in:
menshibin 2024-09-25 17:03:25 +08:00
parent 63d62fdfd3
commit a4b35af11b
11 changed files with 39 additions and 9 deletions

View File

@ -4,8 +4,6 @@
"main": "index.js",
"license": "MIT",
"dependencies": {
"@tdengine/client": "^3.0.1",
"@tdengine/rest": "^3.0.0",
"@tdengine/websocket": "^3.1.0"
}
}

View File

@ -92,9 +92,11 @@ async function all_type_example() {
}
async function test() {
console.log("begin all_type_query")
await json_tag_example()
await all_type_example()
taos.destroy();
console.log("end all_type_query")
}
test()

View File

@ -139,9 +139,11 @@ async function all_type_example() {
}
async function test() {
console.log("begin all_type_stmt")
await json_tag_example()
await all_type_example()
taos.destroy();
console.log("end all_type_stmt")
}
test()

View File

@ -51,7 +51,9 @@ async function schemalessInsert() {
}
async function test() {
console.log("begin json_line_example")
await schemalessInsert();
console.log("end json_line_example")
}
test()

View File

@ -43,7 +43,9 @@ async function schemalessInsert() {
}
async function test() {
console.log("begin line_example")
await schemalessInsert();
console.log("end line_example")
}
test()

View File

@ -74,7 +74,9 @@ async function execSql() {
}
async function test() {
console.log("begin nodejsChecker")
await execSql();
console.log("end nodejsChecker")
}
test()

View File

@ -136,11 +136,13 @@ async function sqlWithReqid() {
// ANCHOR_END: sqlWithReqid
async function test() {
console.log("begin sql_example")
await createDbAndTable();
await insertData();
await queryData();
await sqlWithReqid();
taos.destroy();
console.log("end sql_example")
}
test()

View File

@ -74,7 +74,9 @@ async function stmtInsert() {
}
async function test () {
console.log("begin stmt_example")
await stmtInsert();
console.log("end stmt_example")
}
test()

View File

@ -58,7 +58,9 @@ async function schemalessInsert() {
}
async function test() {
console.log("begin telnet_line_example")
await schemalessInsert();
console.log("end telnet_line_example")
}
test()

View File

@ -1,3 +1,4 @@
const { sleep } = require("@tdengine/websocket");
const taos = require("@tdengine/websocket");
// ANCHOR: create_consumer
@ -49,10 +50,18 @@ async function prepare() {
let createTopic = `CREATE TOPIC IF NOT EXISTS ${topics[0]} AS SELECT * FROM ${db}.${stable}`;
await wsSql.exec(createTopic);
wsSql.close();
}
for (let i = 0; i < 10; i++) {
async function insert() {
let conf = new taos.WSConfig('ws://localhost:6041');
conf.setUser('root');
conf.setPwd('taosdata');
conf.setDb('power');
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);
}
wsSql.close();
}
@ -82,8 +91,11 @@ async function consumer() {
let consumer = null;
try {
await prepare();
consumer = await createConsumer()
await subscribe(consumer)
consumer = await createConsumer();
const allPromises = [];
allPromises.push(subscribe(consumer));
allPromises.push(insert());
await Promise.all(allPromises);
await consumer.unsubscribe();
console.log("Consumer unsubscribed successfully.");
}
@ -102,7 +114,9 @@ async function consumer() {
}
async function test() {
console.log("begin tmq_example")
await consumer();
console.log("end tmq_example")
}
test()

View File

@ -101,7 +101,9 @@ async function consumer() {
// ANCHOR_END: offset
async function test() {
console.log("begin tmq_seek_example")
await consumer();
console.log("end tmq_seek_example")
}
test()