diff --git a/docs/en/05-develop/01-connect/05-node.md b/docs/en/05-develop/01-connect/05-node.md
index f3c1cdfebf962023d3557185e7dacc447184f454..349180b616109eb11cf6d11d565472229afa8a3d 100644
--- a/docs/en/05-develop/01-connect/05-node.md
+++ b/docs/en/05-develop/01-connect/05-node.md
@@ -54,15 +54,7 @@ To obtain the value of cloud token and URL, please log in [TDengine Cloud](https
## Connect
```javascript
-const { options, connect } = require("td2.0-rest-connector");
-
-async function test() {
- options.url = process.env.TDENGINE_CLOUD_URL;
- options.token = process.env.TDENGINE_CLOUD_TOKEN;
- let conn = connect(options);
-}
-
-test();
+{{#include docs/examples/node/connect.js}}
```
diff --git a/docs/en/05-develop/03-insert-data.md b/docs/en/05-develop/03-insert-data.md
index 416fe3a96e3fa42d20090b715072335792fda31f..2956a224a448ff573da96c53aa5858aa5d131b37 100644
--- a/docs/en/05-develop/03-insert-data.md
+++ b/docs/en/05-develop/03-insert-data.md
@@ -55,7 +55,7 @@ In this example, we use `execute` method to execute SQL and get affected rows. T
```go
-
+{{#include docs/examples/go/tutorial/main.go:insert}}
```
diff --git a/docs/en/05-develop/04-query-data.md b/docs/en/05-develop/04-query-data.md
index c5be33c73a09abb0fd9c4b19f49078efca167660..79d0a67fb5de50a34013b17bdfe59c2ebbb8b42b 100644
--- a/docs/en/05-develop/04-query-data.md
+++ b/docs/en/05-develop/04-query-data.md
@@ -167,6 +167,25 @@ Iterate over the result and print each row:
+
+In this example we use `Query` method to execute SQL and get a `sql.Rows` object.
+
+```go
+{{#include docs/examples/go/tutorial/main.go:query:nrc}}
+```
+
+Get column names from rows:
+
+```go
+{{#include docs/examples/go/tutorial/main.go:meta:nrc}}
+```
+
+Iterate over rows and print each row:
+
+```go
+{{#include docs/examples/go/tutorial/main.go:iter}}
+```
+
diff --git a/docs/en/07-tools/03-taosbenchmark.md b/docs/en/07-tools/03-taosbenchmark.md
index 2ad48cd3e5ec2cc134dbb7f94dd5ec442d73cba7..e07cd54b8c18048e2c5e8e9b0996ab5527aa3503 100644
--- a/docs/en/07-tools/03-taosbenchmark.md
+++ b/docs/en/07-tools/03-taosbenchmark.md
@@ -1,6 +1,11 @@
-# taosBenchmark
+---
+title: taosBenchmark
+sidebar_label: taosBenchmark
+---
-taosBenchmark (formerly taosdemo ) is a tool for testing the performance of TDengine products. taosBenchmark can test the performance of TDengine's insert, query, and subscription functions and simulate large amounts of data generated by many devices. taosBenchmark can be configured to generate user defined databases, supertables, subtables, and the time series data to populate these for performance benchmarking. taosBenchark is highly configurable and some of the configurations include the time interval for inserting data, the number of working threads and the capability to insert disordered data. The installer provides taosdemo as a soft link to taosBenchmark for compatibility with past users.
+## Introduction
+
+taosBenchmark (formerly taosdemo ) is a tool for testing the performance of TDengine products. taosBenchmark can test the performance of TDengine's insert, query, and subscription functions and simulate large amounts of data generated by many devices. taosBenchmark can be configured to generate user defined databases, supertables, subtables, and the time series data to populate these for performance benchmarking. taosBenchmark is highly configurable and some of the configurations include the time interval for inserting data, the number of working threads and the capability to insert disordered data. The installer provides taosdemo as a soft link to taosBenchmark for compatibility with past users.
## Installation
@@ -14,9 +19,9 @@ There are two ways to install taosBenchmark:
### Configuration and running methods
-TaosBenchmark needs to be executed on the terminal of the operating system, it supports two configuration methods: [Command-line arguments](#Command-line arguments in detailed) and [JSON configuration file](#Configuration file arguments in detailed). These two methods are mutually exclusive. Users can use `-f ` to specify a configuration file. When running taosBenchmark with command-line arguments to control its behavior, users should use other parameters for configuration, but not the `-f` parameter. In addition, taosBenchmark offers a special way of running without parameters.
+TaosBenchmark needs to be executed on the terminal of the operating system, it supports two configuration methods: [Command-line arguments](#command-line-arguments-in-detail) and [JSON configuration file](#configuration-file-parameters-in-detail). These two methods are mutually exclusive. Users can use `-f ` to specify a configuration file. When running taosBenchmark with command-line arguments to control its behavior, users should use other parameters for configuration, but not the `-f` parameter. In addition, taosBenchmark offers a special way of running without parameters.
-taosBenchmark supports the complete performance testing of TDengine by providing functionaly to write, query, and subscribe. These three functions are mutually exclusive, users can only select one of them each time taosBenchmark runs. The query and subscribe functionalities are only configurable using a json configuration file by specifying the parameter `filetype`, while write can be performed through both the command-line and a configuration file.
+taosBenchmark supports the complete performance testing of TDengine by providing functionally to write, query, and subscribe. These three functions are mutually exclusive, users can only select one of them each time taosBenchmark runs. The query and subscribe functionalities are only configurable using a json configuration file by specifying the parameter `filetype`, while write can be performed through both the command-line and a configuration file.
**Make sure that the TDengine cluster is running correctly before running taosBenchmark. **
@@ -50,9 +55,8 @@ Use the following command-line to run taosBenchmark and control its behavior via
taosBenchmark -f
```
-**Here are a few examples of configuration files:**
-
-#### Example of inserting a scenario JSON configuration file
+#### Configuration file examples
+##### Example of inserting a scenario JSON configuration file
insert.json
@@ -63,7 +67,7 @@ taosBenchmark -f
-#### Query Scenario JSON Profile Example
+##### Query Scenario JSON Profile Example
query.json
@@ -74,7 +78,7 @@ taosBenchmark -f
-#### Subscription JSON configuration example
+##### Subscription JSON configuration example
subscribe.json
@@ -165,7 +169,7 @@ taosBenchmark -A INT,DOUBLE,NCHAR,BINARY\(16\)
specify whether to use escape characters in the super table and sub-table names, the default is no.
- **-C/--chinese** :
- specify whether to use Unicode Chinese characters in nchar and binary, the deault is no.
+ specify whether to use Unicode Chinese characters in nchar and binary, the default is no.
- **-N/--normal-table** :
specify whether taosBenchmark will create only normal tables instead of super tables. The default value is false. It can be used if the insert mode is taosc, stmt, and rest.
@@ -366,7 +370,7 @@ The configuration parameters for querying the sub-tables or the normal tables ar
- **sqls**.
- **sql**: the SQL command to be executed.
- - **result**: the file to save the query result. If it is unspecified, taosBenchark will not save the result.
+ - **result**: the file to save the query result. If it is unspecified, taosBenchmark will not save the result.
#### Configuration parameters of query super table
diff --git a/docs/en/09-connector/03-go.md b/docs/en/09-connector/03-go.md
index 7e4d6368c5cf2130a0e4abf2c3ba1fe88e16a732..62a0486f1a4b60e7262b943e8c956f422d3b4782 100644
--- a/docs/en/09-connector/03-go.md
+++ b/docs/en/09-connector/03-go.md
@@ -1,4 +1,192 @@
---
sidebar_label: Go
title: TDengine Go Connector
----
\ No newline at end of file
+---
+
+`driver-go` is the official Go language connector for TDengine. It implements the [database/sql](https://golang.org/pkg/database/sql/) package, the generic Go language interface to SQL databases. Go developers can use it to develop applications that access TDengine cluster data.
+
+This article describes how to install `driver-go` and connect to TDengine clusters and perform basic operations such as data query and data writing through `driver-go`.
+
+The source code of `driver-go` is hosted on [GitHub](https://github.com/taosdata/driver-go).
+
+## Installation steps
+### Use go get to install
+
+```
+go get -u github.com/taosdata/driver-go/v2@develop
+```
+### Manage with go mod
+
+1. Initialize the project with the `go mod` command.
+
+ ```text
+ go mod init taos-demo
+ ```
+
+2. Introduce taosSql
+
+ ```go
+ import (
+ "database/sql"
+ _ "github.com/taosdata/driver-go/v2/taosSql"
+ )
+ ```
+
+3. Update the dependency packages with `go mod tidy`.
+
+ ```text
+ go mod tidy
+ ```
+
+4. Run the program with `go run taos-demo` or compile the binary with the `go build` command.
+
+ ```text
+ go run taos-demo
+ go build
+ ```
+
+## Create a connection
+
+### Data source name (DSN)
+
+Data source names have a standard format, e.g. [PEAR DB](http://pear.php.net/manual/en/package.database.db.intro-dsn.php), but no type prefix (square brackets indicate optionally):
+
+``` text
+[username[:password]@][protocol[(address)]]/[dbname][?param1=value1&... ¶mN=valueN]
+```
+
+DSN in full form.
+
+```text
+username:password@protocol(address)/dbname?param=value
+```
+
+### Connecting via connector
+
+_taosRestful_ implements Go's `database/sql/driver` interface via `http client`. You can use the [`database/sql`](https://golang.org/pkg/database/sql/) interface by simply introducing the driver.
+
+Use `taosRestful` as `driverName` and use a correct [DSN](#DSN) as `dataSourceName` with the following parameters supported by the DSN.
+
+* `disableCompression` whether to accept compressed data, default is true do not accept compressed data, set to false if transferring data using gzip compression.
+* `readBufferSize` The default size of the buffer for reading data is 4K (4096), which can be adjusted upwards when the query result has a lot of data.
+
+## Sample programs
+
+* [sample program](https://github.com/taosdata/TDengine/tree/develop/examples/go)
+* [Video tutorial](https://www.taosdata.com/blog/2020/11/11/1951.html).
+
+## Usage limitations
+
+Since the REST API is stateless, the `use db` syntax will not work. You need to put the db name into the SQL command, e.g. `create table if not exists tb1 (ts timestamp, a int)` to `create table if not exists test.tb1 (ts timestamp, a int)` otherwise it will report the error `[0x217] Database not specified or available`.
+
+You can also put the db name in the DSN by changing `root:taosdata@http(localhost:6041)/` to `root:taosdata@http(localhost:6041)/test`. This method is supported by taosAdapter since TDengine 2.4.0.5. Executing the `create database` statement when the specified db does not exist will not report an error while executing other queries or writing against that db will report an error.
+
+The complete example is as follows.
+
+```go
+package main
+
+import (
+ "database/sql"
+ "fmt"
+ "time"
+
+ _ "github.com/taosdata/driver-go/v2/taosRestful"
+)
+
+func main() {
+ var taosDSN = "root:taosdata@http(localhost:6041)/test"
+ taos, err := sql.Open("taosRestful", taosDSN)
+ if err != nil {
+ fmt.Println("failed to connect TDengine, err:", err)
+ return
+ }
+ defer taos.Close()
+ taos.Exec("create database if not exists test")
+ taos.Exec("create table if not exists tb1 (ts timestamp, a int)")
+ _, err = taos.Exec("insert into tb1 values(now, 0)(now+1s,1)(now+2s,2)(now+3s,3)")
+ if err != nil {
+ fmt.Println("failed to insert, err:", err)
+ return
+ }
+ rows, err := taos.Query("select * from tb1")
+ if err != nil {
+ fmt.Println("failed to select from table, err:", err)
+ return
+ }
+
+ defer rows.Close()
+ for rows.Next() {
+ var r struct {
+ ts time.Time
+ a int
+ }
+ err := rows.Scan(&r.ts, &r.a)
+ if err != nil {
+ fmt.Println("scan error:\n", err)
+ return
+ }
+ fmt.Println(r.ts, r.a)
+ }
+}
+```
+
+## Frequently Asked Questions
+
+1. Cannot find the package `github.com/taosdata/driver-go/v2/taosRestful`
+
+ Change the `github.com/taosdata/driver-go/v2` line in the require block of the `go.mod` file to `github.com/taosdata/driver-go/v2 develop`, then execute `go mod tidy`.
+
+2. bind interface in database/sql crashes
+
+ REST API does not support parameter binding related interface. It is recommended to use `db.Exec` and `db.Query`.
+
+3. error `[0x217] Database not specified or available` after executing other statements with `use db` statement
+
+ The execution of SQL command in the REST interface is not contextual, so using `use db` statement will not work, see the usage restrictions section above.
+
+4. use `taosSql` without error but use `taosRestful` with error `[0x217] Database not specified or available`
+
+ Because the REST API is stateless, using the `use db` statement will not take effect. See the usage restrictions section above.
+
+5. Upgrade `github.com/taosdata/driver-go/v2/taosRestful`
+
+ Change the `github.com/taosdata/driver-go/v2` line in the `go.mod` file to `github.com/taosdata/driver-go/v2 develop`, then execute `go mod tidy`.
+
+6. `readBufferSize` parameter has no significant effect after being increased
+
+ Increasing `readBufferSize` will reduce the number of `syscall` calls when fetching results. If the query result is smaller, modifying this parameter will not improve performance significantly. If you increase the parameter value too much, the bottleneck will be parsing JSON data. If you need to optimize the query speed, you must adjust the value based on the actual situation to achieve the best query performance.
+
+7. `disableCompression` parameter is set to `false` when the query efficiency is reduced
+
+ When set `disableCompression` parameter to `false`, the query result will be compressed by `gzip` and then transmitted, so you have to decompress the data by `gzip` after getting it.
+
+8. `go get` command can't get the package, or timeout to get the package
+
+ Set Go proxy `go env -w GOPROXY=https://goproxy.cn,direct`.
+
+## Common APIs
+
+### database/sql API
+
+* `sql.Open(DRIVER_NAME string, dataSourceName string) *DB`
+
+ Use This API to open a DB, returning an object of type \*DB.
+
+:::info
+This API is created successfully without checking permissions, but only when you execute a Query or Exec, and check if user/password/host/port is legal.
+
+:::
+
+* `func (db *DB) Exec(query string, args . .interface{}) (Result, error)`
+
+ `sql.Open` built-in method to execute non-query related SQL.
+
+* `func (db *DB) Query(query string, args ... . interface{}) (*Rows, error)`
+
+ `sql.Open` Built-in method to execute query statements.
+
+
+## API Reference
+
+Full API see [driver-go documentation](https://pkg.go.dev/github.com/taosdata/driver-go/v2)
\ No newline at end of file
diff --git a/docs/examples/go/tutorial/go.mod b/docs/examples/go/tutorial/go.mod
new file mode 100644
index 0000000000000000000000000000000000000000..6c65ed9c90842cd32c68f55409b3f868b644b3ea
--- /dev/null
+++ b/docs/examples/go/tutorial/go.mod
@@ -0,0 +1,11 @@
+module tdengine.com/tutorial
+
+go 1.17
+
+require github.com/taosdata/driver-go/v2 v2.0.1-0.20220523115057-e3107e343c03
+
+require (
+ github.com/json-iterator/go v1.1.12 // indirect
+ github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 // indirect
+ github.com/modern-go/reflect2 v1.0.2 // indirect
+)
diff --git a/docs/examples/go/tutorial/go.sum b/docs/examples/go/tutorial/go.sum
new file mode 100644
index 0000000000000000000000000000000000000000..0136c270d6d8fe733451ef8523ff05b633de6dc9
--- /dev/null
+++ b/docs/examples/go/tutorial/go.sum
@@ -0,0 +1,21 @@
+github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
+github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
+github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
+github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
+github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OHLH3mGKHDcjJRFFRrJa6eAM5H+CtDdOsPc=
+github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
+github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
+github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
+github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
+github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
+github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
+github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
+github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
+github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
+github.com/taosdata/driver-go/v2 v2.0.1-0.20220523115057-e3107e343c03 h1:uMJhzerYX73ksAuaOsVtIWk3q3m+6ckMuxT3RvA4HCw=
+github.com/taosdata/driver-go/v2 v2.0.1-0.20220523115057-e3107e343c03/go.mod h1:ZAb4yDucTytX1Gy69F3nTRV+lEXmjkyF4J6OiYCR9NI=
+gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
+gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
+gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
diff --git a/docs/examples/go/tutorial/main.go b/docs/examples/go/tutorial/main.go
new file mode 100644
index 0000000000000000000000000000000000000000..768e4d0ad1ce4cedf747655a83d7ee3375b46083
--- /dev/null
+++ b/docs/examples/go/tutorial/main.go
@@ -0,0 +1,77 @@
+package main
+
+import (
+ "database/sql"
+ "fmt"
+ "os"
+ "time"
+
+ _ "github.com/taosdata/driver-go/v2/taosRestful"
+)
+
+func main() {
+ dsn := os.Getenv("TDENGINE_GO_DSN")
+ taos, err := sql.Open("taosRestful", dsn)
+ if err != nil {
+ fmt.Println(err)
+ return
+ }
+ defer taos.Close()
+ // ANCHOR: insert
+ _, err = taos.Exec("DROP DATABASE IF EXISTS power")
+ if err != nil {
+ fmt.Println("failed to drop database, err:", err)
+ return
+ }
+ _, err = taos.Exec("CREATE DATABASE power")
+ if err != nil {
+ fmt.Println("failed to create database, err:", err)
+ return
+ }
+ _, err = taos.Exec("CREATE STABLE power.meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS (location BINARY(64), groupId INT)")
+ if err != nil {
+ fmt.Println("failed to create stable, err:", err)
+ return
+ }
+ result, err := taos.Exec("INSERT INTO power.d1001 USING power.meters TAGS(California.SanFrancisco, 2) VALUES ('2018-10-03 14:38:05.000', 10.30000, 219, 0.31000) ('2018-10-03 14:38:15.000', 12.60000, 218, 0.33000) ('2018-10-03 14:38:16.800', 12.30000, 221, 0.31000) power.d1002 USING power.meters TAGS(California.SanFrancisco, 3) VALUES ('2018-10-03 14:38:16.650', 10.30000, 218, 0.25000)")
+ if err != nil {
+ fmt.Println("failed to insert, err:", err)
+ return
+ }
+ rowsAffected, err := result.RowsAffected()
+ if err != nil {
+ fmt.Println("failed to get affected rows, err:", err)
+ return
+ }
+ fmt.Println("RowsAffected", rowsAffected) // RowsAffected 4
+ // ANCHOR_END: insert
+ // ANCHOR: query
+ rows, err := taos.Query("SELECT ts, current FROM power.meters LIMIT 2")
+ if err != nil {
+ fmt.Println("failed to select from table, err:", err)
+ return
+ }
+ defer rows.Close()
+ // ANCHOR_END: query
+ // ANCHOR: meta
+ // print column names
+ colNames, _ := rows.Columns()
+ fmt.Println(colNames)
+ // ANCHOR_END: meta
+ // ANCHOR: iter
+ for rows.Next() {
+ var r struct {
+ ts time.Time
+ current float32
+ }
+ err := rows.Scan(&r.ts, &r.current)
+ if err != nil {
+ fmt.Println("scan error:\n", err)
+ return
+ }
+ fmt.Println(r.ts, r.current)
+ }
+ // 2018-10-03 14:38:05 +0000 UTC 10.3
+ // 2018-10-03 14:38:15 +0000 UTC 12.6
+ // ANCHOR_END: iter
+}
diff --git a/docs/examples/node/restexample/connect.js b/docs/examples/node/connect.js
similarity index 53%
rename from docs/examples/node/restexample/connect.js
rename to docs/examples/node/connect.js
index b84ce2fadf9177983701582b05200986ea9d5ba7..c55e0c60461463d37156bb189a1bf0b59511194f 100644
--- a/docs/examples/node/restexample/connect.js
+++ b/docs/examples/node/connect.js
@@ -1,20 +1,16 @@
const { options, connect } = require("td2.0-rest-connector");
async function test() {
- options.path = "/rest/sqlt";
- options.host = "localhost";
+ options.url = process.env.TDENGINE_CLOUD_URL;
+ options.token = process.env.TDENGINE_CLOUD_TOKEN;
let conn = connect(options);
let cursor = conn.cursor();
try {
- let res = await cursor.query("SELECT server_version()");
+ let res = await cursor.query("select server_version()");
res.toString();
} catch (err) {
console.log(err);
}
}
-test();
-// output:
-// server_version() |
-// ===================
-// 2.4.0.12 |
+test();
diff --git a/docs/examples/node/nativeexample/async_query_example.js b/docs/examples/node/nativeexample/async_query_example.js
deleted file mode 100644
index 25b78bc48a82454cc0f9db69b77323a00f3852b4..0000000000000000000000000000000000000000
--- a/docs/examples/node/nativeexample/async_query_example.js
+++ /dev/null
@@ -1,21 +0,0 @@
-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
diff --git a/docs/examples/node/nativeexample/connect.js b/docs/examples/node/nativeexample/connect.js
deleted file mode 100644
index da791c566e3aa40315b6f35cfeca704040cd8107..0000000000000000000000000000000000000000
--- a/docs/examples/node/nativeexample/connect.js
+++ /dev/null
@@ -1,13 +0,0 @@
-const taos = require("td2.0-connector");
-
-var conn = taos.connect({
- host: "localhost",
- port: 6030,
- user: "root",
- password: "taosdata",
-});
-conn.close();
-
-// run with: node connect.js
-// output:
-// Successfully connected to TDengine
diff --git a/docs/examples/node/nativeexample/influxdb_line_example.js b/docs/examples/node/nativeexample/influxdb_line_example.js
deleted file mode 100644
index 2050bee54506a3ee6fe7d89de97b3b41334dd4a6..0000000000000000000000000000000000000000
--- a/docs/examples/node/nativeexample/influxdb_line_example.js
+++ /dev/null
@@ -1,34 +0,0 @@
-const taos = require("td2.0-connector");
-
-const conn = taos.connect({
- host: "localhost",
-});
-
-const cursor = conn.cursor();
-
-function createDatabase() {
- cursor.execute("CREATE DATABASE test");
- cursor.execute("USE test");
-}
-
-function insertData() {
- const lines = [
- "meters,location=California.LosAngeles,groupid=2 current=11.8,voltage=221,phase=0.28 1648432611249",
- "meters,location=California.LosAngeles,groupid=2 current=13.4,voltage=223,phase=0.29 1648432611250",
- "meters,location=California.LosAngeles,groupid=3 current=10.8,voltage=223,phase=0.29 1648432611249",
- "meters,location=California.LosAngeles,groupid=3 current=11.3,voltage=221,phase=0.35 1648432611250",
- ];
- cursor.schemalessInsert(
- lines,
- taos.SCHEMALESS_PROTOCOL.TSDB_SML_LINE_PROTOCOL,
- taos.SCHEMALESS_PRECISION.TSDB_SML_TIMESTAMP_MILLI_SECONDS
- );
-}
-
-try {
- createDatabase();
- insertData();
-} finally {
- cursor.close();
- conn.close();
-}
diff --git a/docs/examples/node/nativeexample/insert_example.js b/docs/examples/node/nativeexample/insert_example.js
deleted file mode 100644
index ade9d83158362cbf00a856b43a973de31def7601..0000000000000000000000000000000000000000
--- a/docs/examples/node/nativeexample/insert_example.js
+++ /dev/null
@@ -1,31 +0,0 @@
-const taos = require("td2.0-connector");
-
-const conn = taos.connect({
- host: "localhost",
-});
-
-const cursor = conn.cursor();
-try {
- cursor.execute("CREATE DATABASE power");
- cursor.execute("USE power");
- cursor.execute(
- "CREATE STABLE meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS (location BINARY(64), groupId INT)"
- );
- var sql = `INSERT INTO power.d1001 USING power.meters TAGS(California.SanFrancisco, 2) VALUES ('2018-10-03 14:38:05.000', 10.30000, 219, 0.31000) ('2018-10-03 14:38:15.000', 12.60000, 218, 0.33000) ('2018-10-03 14:38:16.800', 12.30000, 221, 0.31000)
-power.d1002 USING power.meters TAGS(California.SanFrancisco, 3) VALUES ('2018-10-03 14:38:16.650', 10.30000, 218, 0.25000)
-power.d1003 USING power.meters TAGS(California.LosAngeles, 2) VALUES ('2018-10-03 14:38:05.500', 11.80000, 221, 0.28000) ('2018-10-03 14:38:16.600', 13.40000, 223, 0.29000)
-power.d1004 USING power.meters TAGS(California.LosAngeles, 3) VALUES ('2018-10-03 14:38:05.000', 10.80000, 223, 0.29000) ('2018-10-03 14:38:06.500', 11.50000, 221, 0.35000)`;
- cursor.execute(sql);
-} finally {
- cursor.close();
- conn.close();
-}
-
-// run with: node insert_example.js
-// output:
-// Successfully connected to TDengine
-// Query OK, 0 row(s) affected (0.00509570s)
-// Query OK, 0 row(s) affected (0.00130880s)
-// Query OK, 0 row(s) affected (0.00467900s)
-// Query OK, 8 row(s) affected (0.04043550s)
-// Connection is closed
diff --git a/docs/examples/node/nativeexample/multi_bind_example.js b/docs/examples/node/nativeexample/multi_bind_example.js
deleted file mode 100644
index 6ef8b30c097393fef8c6a2837f8683c736b363f1..0000000000000000000000000000000000000000
--- a/docs/examples/node/nativeexample/multi_bind_example.js
+++ /dev/null
@@ -1,53 +0,0 @@
-const taos = require("td2.0-connector");
-
-const conn = taos.connect({
- host: "localhost",
-});
-
-const cursor = conn.cursor();
-
-function prepareSTable() {
- cursor.execute("CREATE DATABASE power");
- cursor.execute("USE power");
- cursor.execute(
- "CREATE STABLE meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS (location BINARY(64), groupId INT)"
- );
-}
-
-//ANCHOR: insertData
-function insertData() {
- // init
- cursor.stmtInit();
- // prepare
- cursor.stmtPrepare(
- "INSERT INTO ? USING meters TAGS(?, ?) VALUES(?, ?, ?, ?)"
- );
-
- // bind table name and tags
- let tagBind = new taos.TaosBind(2);
- tagBind.bindBinary("California.SanFrancisco");
- tagBind.bindInt(2);
- cursor.stmtSetTbnameTags("d1001", tagBind.getBind());
-
- // bind values
- let valueBind = new taos.TaosMultiBindArr(4);
- valueBind.multiBindTimestamp([1648432611249, 1648432611749]);
- valueBind.multiBindFloat([10.3, 12.6]);
- valueBind.multiBindInt([219, 218]);
- valueBind.multiBindFloat([0.31, 0.33]);
- cursor.stmtBindParamBatch(valueBind.getMultiBindArr());
- cursor.stmtAddBatch();
-
- // execute
- cursor.stmtExecute();
- cursor.stmtClose();
-}
-//ANCHOR_END: insertData
-
-try {
- prepareSTable();
- insertData();
-} finally {
- cursor.close();
- conn.close();
-}
diff --git a/docs/examples/node/nativeexample/opentsdb_json_example.js b/docs/examples/node/nativeexample/opentsdb_json_example.js
deleted file mode 100644
index 2d78444a3f805bc77ab5e11925a28dd18fe221fe..0000000000000000000000000000000000000000
--- a/docs/examples/node/nativeexample/opentsdb_json_example.js
+++ /dev/null
@@ -1,55 +0,0 @@
-const taos = require("td2.0-connector");
-
-const conn = taos.connect({
- host: "localhost",
-});
-
-const cursor = conn.cursor();
-
-function createDatabase() {
- cursor.execute("CREATE DATABASE test");
- cursor.execute("USE test");
-}
-
-function insertData() {
- const lines = [
- {
- metric: "meters.current",
- timestamp: 1648432611249,
- value: 10.3,
- tags: { location: "California.SanFrancisco", groupid: 2 },
- },
- {
- metric: "meters.voltage",
- timestamp: 1648432611249,
- value: 219,
- tags: { location: "California.LosAngeles", groupid: 1 },
- },
- {
- metric: "meters.current",
- timestamp: 1648432611250,
- value: 12.6,
- tags: { location: "California.SanFrancisco", groupid: 2 },
- },
- {
- metric: "meters.voltage",
- timestamp: 1648432611250,
- value: 221,
- tags: { location: "California.LosAngeles", groupid: 1 },
- },
- ];
-
- cursor.schemalessInsert(
- [JSON.stringify(lines)],
- taos.SCHEMALESS_PROTOCOL.TSDB_SML_JSON_PROTOCOL,
- taos.SCHEMALESS_PRECISION.TSDB_SML_TIMESTAMP_NOT_CONFIGURED
- );
-}
-
-try {
- createDatabase();
- insertData();
-} finally {
- cursor.close();
- conn.close();
-}
diff --git a/docs/examples/node/nativeexample/opentsdb_telnet_example.js b/docs/examples/node/nativeexample/opentsdb_telnet_example.js
deleted file mode 100644
index 7f80f558838e18f07ad79e580e7d08638b74e940..0000000000000000000000000000000000000000
--- a/docs/examples/node/nativeexample/opentsdb_telnet_example.js
+++ /dev/null
@@ -1,38 +0,0 @@
-const taos = require("td2.0-connector");
-
-const conn = taos.connect({
- host: "localhost",
-});
-
-const cursor = conn.cursor();
-
-function createDatabase() {
- cursor.execute("CREATE DATABASE test");
- cursor.execute("USE test");
-}
-
-function insertData() {
- const lines = [
- "meters.current 1648432611249 10.3 location=California.SanFrancisco groupid=2",
- "meters.current 1648432611250 12.6 location=California.SanFrancisco groupid=2",
- "meters.current 1648432611249 10.8 location=California.LosAngeles groupid=3",
- "meters.current 1648432611250 11.3 location=California.LosAngeles groupid=3",
- "meters.voltage 1648432611249 219 location=California.SanFrancisco groupid=2",
- "meters.voltage 1648432611250 218 location=California.SanFrancisco groupid=2",
- "meters.voltage 1648432611249 221 location=California.LosAngeles groupid=3",
- "meters.voltage 1648432611250 217 location=California.LosAngeles groupid=3",
- ];
- cursor.schemalessInsert(
- lines,
- taos.SCHEMALESS_PROTOCOL.TSDB_SML_TELNET_PROTOCOL,
- taos.SCHEMALESS_PRECISION.TSDB_SML_TIMESTAMP_NOT_CONFIGURED
- );
-}
-
-try {
- createDatabase();
- insertData();
-} finally {
- cursor.close();
- conn.close();
-}
diff --git a/docs/examples/node/nativeexample/param_bind_example.js b/docs/examples/node/nativeexample/param_bind_example.js
deleted file mode 100644
index c7e04c71a0d19ff8666f3d43fe09109009741266..0000000000000000000000000000000000000000
--- a/docs/examples/node/nativeexample/param_bind_example.js
+++ /dev/null
@@ -1,57 +0,0 @@
-const taos = require("td2.0-connector");
-
-const conn = taos.connect({
- host: "localhost",
-});
-
-const cursor = conn.cursor();
-
-function prepareSTable() {
- cursor.execute("CREATE DATABASE power");
- cursor.execute("USE power");
- cursor.execute(
- "CREATE STABLE meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS (location BINARY(64), groupId INT)"
- );
-}
-
-function insertData() {
- // init
- cursor.stmtInit();
- // prepare
- cursor.stmtPrepare(
- "INSERT INTO ? USING meters TAGS(?, ?) VALUES(?, ?, ?, ?)"
- );
-
- // bind table name and tags
- let tagBind = new taos.TaosBind(2);
- tagBind.bindBinary("California.SanFrancisco");
- tagBind.bindInt(2);
- cursor.stmtSetTbnameTags("d1001", tagBind.getBind());
-
- // bind values
- let rows = [
- [1648432611249, 10.3, 219, 0.31],
- [1648432611749, 12.6, 218, 0.33],
- ];
- for (let row of rows) {
- let valueBind = new taos.TaosBind(4);
- valueBind.bindTimestamp(row[0]);
- valueBind.bindFloat(row[1]);
- valueBind.bindInt(row[2]);
- valueBind.bindFloat(row[3]);
- cursor.stmtBindParam(valueBind.getBind());
- cursor.stmtAddBatch();
- }
-
- // execute
- cursor.stmtExecute();
- cursor.stmtClose();
-}
-
-try {
- prepareSTable();
- insertData();
-} finally {
- cursor.close();
- conn.close();
-}
diff --git a/docs/examples/node/nativeexample/query_example.js b/docs/examples/node/nativeexample/query_example.js
deleted file mode 100644
index a51bc939ae8dc458f019ac3bf006d9320dfdee81..0000000000000000000000000000000000000000
--- a/docs/examples/node/nativeexample/query_example.js
+++ /dev/null
@@ -1,17 +0,0 @@
-const taos = require("td2.0-connector");
-
-const conn = taos.connect({ host: "localhost", database: "power" });
-const cursor = conn.cursor();
-const query = cursor.query("SELECT ts, current FROM meters LIMIT 2");
-query.execute().then(function (result) {
- result.pretty();
-});
-
-// output:
-// Successfully connected to TDengine
-// Query OK, 2 row(s) in set (0.00317767s)
-
-// ts | current |
-// =======================================================
-// 2018-10-03 14:38:05.000 | 10.3 |
-// 2018-10-03 14:38:15.000 | 12.6 |
diff --git a/docs/examples/node/nativeexample/subscribe_demo.js b/docs/examples/node/nativeexample/subscribe_demo.js
deleted file mode 100644
index bdf0c98687c359ba20664e869a25690dffbabd29..0000000000000000000000000000000000000000
--- a/docs/examples/node/nativeexample/subscribe_demo.js
+++ /dev/null
@@ -1,4 +0,0 @@
-const taos = require("td2.0-connector");
-
-const conn = taos.connect({ host: "localhost", database: "power" });
-// 未完成
\ No newline at end of file
diff --git a/docs/examples/node/package.json b/docs/examples/node/package.json
index f56196d2e5011b1c56e59d78d2ce5fdda98205e9..51b9cf5172ff7db27e48133a3b0ee45c78ae335a 100644
--- a/docs/examples/node/package.json
+++ b/docs/examples/node/package.json
@@ -4,7 +4,6 @@
"main": "index.js",
"license": "MIT",
"dependencies": {
- "td2.0-connector": "^2.0.12",
- "td2.0-rest-connector": "^1.0.0"
+ "td2.0-rest-connector": "^1.0.5"
}
}