@tdengine/websocket 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,59 @@
1
+ # WebSocket APIs
2
+
3
+ ## Bulk Pulling
4
+
5
+ ### DSN
6
+
7
+ User can connect to the TDengine by passing DSN to WebSocket client. The description about the DSN like before.
8
+
9
+ ```text
10
+ [+<protocol>]://[[<username>:<password>@]<host>:<port>][/<database>][?<p1>=<v1>[&<p2>=<v2>]]
11
+ |------------|---|-----------|-----------|------|------|------------|-----------------------|
12
+ | protocol | | username | password | host | port | database | params |
13
+ ```
14
+
15
+ - **protocol**: Display using websocket protocol to establish connection. eg. `ws://localhost:6041`
16
+ - **username/password**: Database's username and password.
17
+ - **host/port**: Declare host and port. eg. `localhost:6041`
18
+ - **database**: Optional, use to specify database name.
19
+ - **params**: Other parameters. Like cloud Token.
20
+
21
+ A complete DSN string example:
22
+
23
+ ```text
24
+ ws://localhost:6041/test
25
+ ```
26
+
27
+ ### Basic Usage
28
+
29
+ ``` typescript
30
+ import {connect} from '@tdengine/websocket'
31
+ let dsn = "ws://host:port/rest/ws/db"
32
+ // create an instance of taoWS, while the returned websocket connection of the returned instance 'ws' may is not in 'OPEN' status
33
+ var ws = connect(dsn)
34
+ ```
35
+
36
+ ``` typescript
37
+ // build connect with tdengine
38
+ ws.connect().then(connectRes=>console.log(connectRes)).catch(e=>{/*do some thing to handle error*/})
39
+ ```
40
+
41
+ ``` typescript
42
+ //query data with SQL
43
+ ws.query(sql).then(taosResult=>{console.log(taosResult)}).catch(e=>{/*do some thing to handle error*/})
44
+ ```
45
+
46
+ ```typescript
47
+ // get client version
48
+ ws.version().then(version=>console.log(version)).catch(e=>{/*do some thing to handle error*/})
49
+ ```
50
+
51
+ ``` typescript
52
+ // get current WebSocket connection status
53
+ let status:number = ws.status()
54
+ ```
55
+
56
+ ``` typescript
57
+ // close current WebSocket connection
58
+ ws.close();
59
+ ```