Skip to content

Commit

Permalink
Merge pull request #73 from taosdata/fix/TD-33562
Browse files Browse the repository at this point in the history
Fix/td 33562
  • Loading branch information
menshibin authored Feb 5, 2025
2 parents 845d8be + 278f730 commit 0883b9f
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 83 deletions.
File renamed without changes.
79 changes: 38 additions & 41 deletions README-CN.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,35 @@
<!-- omit in toc -->
# TDengine Node.js Connector
<!-- omit in toc -->

| Github Action Tests | CodeCov |
|--------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------|
| ![actions](https://github.com/taosdata/taos-connector-node/actions/workflows/push.yaml/badge.svg) | [![codecov](https://codecov.io/gh/taosdata/taos-connector-node/graph/badge.svg?token=5379a80b-063f-48c2-ab56-09564e7ca777)](https://codecov.io/gh/taosdata/taos-connector-node) |
[![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/taosdata/taos-connector-node/build.yaml)](https://github.com/taosdata/taos-connector-node/actions/workflows/build.yaml)
[![codecov](https://codecov.io/gh/taosdata/taos-connector-node/graph/badge.svg?token=5379a80b-063f-48c2-ab56-09564e7ca777)](https://codecov.io/gh/taosdata/taos-connector-node)
![GitHub commit activity](https://img.shields.io/github/commit-activity/m/taosdata/taos-connector-node)
![GitHub License](https://img.shields.io/github/license/taosdata/taos-connector-node)
[![NPM Version](https://shields.io/npm/v/@tdengine/websocket)](https://www.npmjs.com/package/@tdengine/websocket)
<br />
[![Twitter Follow](https://img.shields.io/twitter/follow/tdenginedb?label=TDengine&style=social)](https://twitter.com/tdenginedb)
[![YouTube Channel](https://img.shields.io/badge/Subscribe_@tdengine--white?logo=youtube&style=social)](https://www.youtube.com/@tdengine)
[![Discord Community](https://img.shields.io/badge/Join_Discord--white?logo=discord&style=social)](https://discord.com/invite/VZdSuUg4pS)
[![LinkedIn](https://img.shields.io/badge/Follow_LinkedIn--white?logo=linkedin&style=social)](https://www.linkedin.com/company/tdengine)
[![StackOverflow](https://img.shields.io/badge/Ask_StackOverflow--white?logo=stackoverflow&style=social&logoColor=orange)](https://stackoverflow.com/questions/tagged/tdengine)


[English](README.md) | 简体中文

<!-- omit in toc -->

## 目录
<!-- omit in toc -->

- [目录](#目录)
- [1. 简介](#1-简介)
- [1.1 Node.js 版本兼容性](#11-nodejs-版本兼容性)
- [1.2 支持的平台](#12-支持的平台)
- [2. 获取驱动](#2-获取驱动)
- [3. 文档](#3-文档)
- [4. 前置条件](#4-前置条件)
- [5. 构建](#5-构建)
- [6. 测试](#6-测试)
- [6.1 运行测试](#61-运行测试)
- [6.2 添加用例](#62-添加用例)
- [6.3 性能测试](#63-性能测试)
- [2. 文档](#2-文档)
- [3. 前置条件](#3-前置条件)
- [4. 构建](#4-构建)
- [5. 测试](#5-测试)
- [5.1 运行测试](#51-运行测试)
- [5.2 添加用例](#52-添加用例)
- [5.3 性能测试](#53-性能测试)
- [6. CI/CD](#6-cicd)
- [7. 提交 Issue](#7-提交-issue)
- [8. 提交 PR](#8-提交-pr)
- [9. 引用](#9-引用)
Expand All @@ -33,41 +40,26 @@

@tdengine/websocket 是 TDengine 官方专为 Node.js 开发人员精心设计的一款高效连接器,它借助 taosAdapter 组件提供的 WebSocket API 与 TDengine 建立连接,摆脱了对 TDengine 客户端驱动的依赖 ,为开发者开辟了一条便捷的开发路径。凭借这一强大工具,开发人员能够轻松构建面向 TDengine 集群的应用程序。不管是执行复杂的 SQL 写入与查询任务,还是实现灵活的无模式写入操作,亦或是达成对实时性要求极高的订阅功能,这款连接器都能轻松胜任、完美实现,全方位满足多样化的数据交互需求。

### 1.1 Node.js 版本兼容性

支持 Node.js 14 及以上版本。

### 1.2 支持的平台

支持所有能运行 Node.js 的平台。
## 2. 文档

## 2. 获取驱动
- 使用 Node.js Connector, 请参考 [开发指南](https://docs.taosdata.com/develop/),包含了应用如何引入 @tdengine/websocket 和数据写入、查询、无模式写入、参数绑定和数据订阅等示例。
- 其他参考信息请看 [参考手册](https://docs.taosdata.com/reference/connector/node/),包含了版本历史、数据类型、示例程序汇总、API 说明和常见问题等。
- 本README主要是为想自己贡献、编译、测试 Node.js Connector 的开发者写的。如果要学习 TDengine,可以浏览 [官方文档](https://docs.taosdata.com/)

使用 npm 安装 Node.js 连接器

```shell
npm install @tdengine/websocket
```

## 3. 文档

- 开发示例请见 [开发指南](https://docs.taosdata.com/develop/)
- 版本历史、TDengine 对应版本以及 API 说明请见 [参考手册](https://docs.taosdata.com/reference/connector/node/)

## 4. 前置条件
## 3. 前置条件

- 安装 Node.js 开发环境, 使用14以上版本,[下载 Node.js](https://nodejs.org/en/download/)
- 使用 npm 安装 Node.js 连接器。
- 使用 npm 安装 TypeScript 5.3.3 以上版本。
- 本地已经部署 TDengine,具体步骤请参考 部署服务端,且已经启动 `taosd``taosAdapter`
- 本地已经部署 TDengine,具体步骤请参考 [部署服务端](https://docs.taosdata.com/get-started/package/),且已经启动 `taosd``taosAdapter`

## 5. 构建
## 4. 构建

在项目 `nodejs` 目录下执行 `tsc` 构建项目。

## 6. 测试
## 5. 测试

### 6.1 运行测试
### 5.1 运行测试

在项目的 `nodejs` 目录下,执行 `npm run test` 命令,即可运行 `test/bulkPulling` 目录中的所有测试用例。这些测试用例将连接本地的 `TDengine` 服务器与 `taosAdapter` 进行相关测试。在终端内将实时输出各测试用例的执行结果。待整个测试流程结束,如果所有用例通过,没有 Failures 和 Errors, 并且还会给出相应的覆盖率数据。

Expand All @@ -79,14 +71,18 @@ Time: 20.373 s
Ran all test suites.
```

### 6.2 添加用例
### 5.2 添加用例

所有测试在项目的 `nodejs/test/bulkPulling` 目录下,可以新增加测试文件或者在已有的测试文件中添加用例。用例使用 jest 框架,一般在 `beforeAll` 方法中建立连接和创建数据库,在 `afterAll` 方法中删除数据库和释放连接。

### 6.3 性能测试
### 5.3 性能测试

性能测试还在开发中。

## 6. CI/CD
- [Build Workflow](https://github.com/taosdata/taos-connector-node/actions/workflows/build.yaml)
- [Code Coverage](https://app.codecov.io/gh/taosdata/taos-connector-node)

## 7. 提交 Issue

我们欢迎提交 [GitHub Issue](https://github.com/taosdata/taos-connector-node/issues/new?template=Blank+issue)。 提交时请说明下面信息:
Expand All @@ -106,6 +102,7 @@ Ran all test suites.
1. 修改代码,保证所有单元测试通过,并增加新的单元测试验证修改。
1. 提交修改到远端分支 (`git push origin my_branch`)。
1. 在 GitHub 上创建一个 Pull Request ([how to create a pull request](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request))。
1. 提交 PR 后,可以通过 [Pull Request](https://github.com/taosdata/taos-connector-node/pulls) 找到自己的 PR,点击对应链接进去可以看到自己 PR CI 是否通过,如果通过会显示 “All checks have passed”。无论 CI 是否通过,都可以点击 “Show all checks” -> “Details” 来查看详细用例日志。
1. 提交 PR 后,如果 CI 通过,可以在 [codecov](https://app.codecov.io/gh/taosdata/taos-connector-node/pulls) 页面找到自己 PR,看单测覆盖率。

## 9. 引用
Expand Down
79 changes: 37 additions & 42 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,33 @@
<!-- omit in toc -->
# TDengine Node.js Connector
<!-- omit in toc -->

| Github Action Tests | CodeCov |
|--------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------|
| ![actions](https://github.com/taosdata/taos-connector-node/actions/workflows/push.yaml/badge.svg) | [![codecov](https://codecov.io/gh/taosdata/taos-connector-node/graph/badge.svg?token=5379a80b-063f-48c2-ab56-09564e7ca777)](https://codecov.io/gh/taosdata/taos-connector-node) |
[![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/taosdata/taos-connector-node/build.yaml)](https://github.com/taosdata/taos-connector-node/actions/workflows/build.yaml)
[![codecov](https://codecov.io/gh/taosdata/taos-connector-node/graph/badge.svg?token=5379a80b-063f-48c2-ab56-09564e7ca777)](https://codecov.io/gh/taosdata/taos-connector-node)
![GitHub commit activity](https://img.shields.io/github/commit-activity/m/taosdata/taos-connector-node)
![GitHub License](https://img.shields.io/github/license/taosdata/taos-connector-node)
[![NPM Version](https://shields.io/npm/v/@tdengine/websocket)](https://www.npmjs.com/package/@tdengine/websocket)
<br />
[![Twitter Follow](https://img.shields.io/twitter/follow/tdenginedb?label=TDengine&style=social)](https://twitter.com/tdenginedb)
[![YouTube Channel](https://img.shields.io/badge/Subscribe_@tdengine--white?logo=youtube&style=social)](https://www.youtube.com/@tdengine)
[![Discord Community](https://img.shields.io/badge/Join_Discord--white?logo=discord&style=social)](https://discord.com/invite/VZdSuUg4pS)
[![LinkedIn](https://img.shields.io/badge/Follow_LinkedIn--white?logo=linkedin&style=social)](https://www.linkedin.com/company/tdengine)
[![StackOverflow](https://img.shields.io/badge/Ask_StackOverflow--white?logo=stackoverflow&style=social&logoColor=orange)](https://stackoverflow.com/questions/tagged/tdengine)

English | [简体中文](README-CN.md)

<!-- omit in toc -->
## Table of Contents
<!-- omit in toc -->

- [Table of Contents](#table-of-contents)
- [1. Introduction](#1-introduction)
- [1.1 Node.js Version Compatibility](#11-nodejs-version-compatibility)
- [1.2 Supported Platforms](#12-supported-platforms)
- [2. Get the Driver](#2-get-the-driver)
- [3. Documentation](#3-documentation)
- [4. Prerequisites](#4-prerequisites)
- [5. Build](#5-build)
- [6. Testing](#6-testing)
- [6.1 Test Execution](#61-test-execution)
- [6.2 Test Case Addition](#62-test-case-addition)
- [6.3 Performance Testing](#63-performance-testing)
- [2. Documentation](#2-documentation)
- [3. Prerequisites](#3-prerequisites)
- [4. Build](#4-build)
- [5. Testing](#5-testing)
- [5.1 Test Execution](#51-test-execution)
- [5.2 Test Case Addition](#52-test-case-addition)
- [5.3 Performance Testing](#53-performance-testing)
- [6. CI/CD](#6-cicd)
- [7. Submitting Issues](#7-submitting-issues)
- [8. Submitting PRs](#8-submitting-prs)
- [9. References](#9-references)
Expand All @@ -32,42 +37,26 @@ English | [简体中文](README-CN.md)

@tdengine/websocket is an efficient connector specially designed by TDengine for Node.js developers. It uses the WebSocket API provided by the taosAdapter component to establish a connection with TDengine, eliminating the dependence on TDengine client drivers and opening up a convenient development path for developers. With this powerful tool, developers can easily build applications for TDengine clusters. Whether it is performing complex SQL write and query tasks, implementing flexible schemaless write operations, or achieving highly real-time subscription functionality, this connector can easily and perfectly meet diverse data interaction needs in all aspects.

### 1.1 Node.js Version Compatibility

Supports Node.js 14 and above.

### 1.2 Supported Platforms
## 2. Documentation

Support all platforms that can run Node.js.
- To use Node.js connector, please check [Developer Guide](https://docs.tdengine.com/developer-guide/), which includes how an application can introduce the `@tdengine/websocket`, as well as examples of data writing, querying, schemaless writing, parameter binding, and data subscription.
- For other reference information, please check [Reference Manual](https://docs.tdengine.com/tdengine-reference/client-libraries/node/), which includes version history, data types, example programs, API descriptions, and FAQs.
- This quick guide is mainly for developers who like to contribute/build/test the Node.js connector by themselves. To learn about TDengine, you can visit the [official documentation](https://docs.tdengine.com).

## 2. Get the Driver

Install the Node.js connector using npm.

```shell
npm install @tdengine/websocket
```

## 3. Documentation

- For development examples, see [Developer Guide](https://docs.tdengine.com/developer-guide/), which includes examples of data writing, querying, schemaless writing, parameter binding, and data subscription.
- For other reference information, see [Reference Manual](https://docs.tdengine.com/tdengine-reference/client-libraries/node/), which includes version history, data types, example programs, API descriptions, and FAQs.


## 4. Prerequisites
## 3. Prerequisites

- Install the Node.js development environment, using version 14 or above. Download link: [https://nodejs.org/en/download/](https://nodejs.org/en/download/)
- Install the Node.js connector using npm.
- Install TypeScript 5.3.3 and above using npm.
- TDengine has been deployed locally. For specific steps, please refer to Deploy TDengine, and `taosd` and `taosAdapter` have been started.
- TDengine has been deployed locally. For specific steps, please refer to [Deploy TDengine](https://docs.tdengine.com/get-started/deploy-from-package/), and `taosd` and `taosAdapter` have been started.

## 5. Build
## 4. Build

Execute `tsc` to build the project in the 'nodejs' directory.

## 6. Testing
## 5. Testing

### 6.1 Test Execution
### 5.1 Test Execution

Execute `npm run test` in the project directory to run the tests. The test cases will connect to the local TDengine server and taosAdapter for testing.
After running the tests, the result similar to the following will be printed eventually. If all test cases pass, without any failures or errors.
Expand All @@ -80,15 +69,20 @@ Time: 20.373 s
Ran all test suites.
```

### 6.2 Test Case Addition
### 5.2 Test Case Addition

All tests are located in the `nodejs/test/bulkPulling` directory of the project. You can add new test files or add test cases in existing test files.
The test cases use the jest framework. Generally, a connection is established and a database is created in the `beforeAll` method, and the database is droped and the connection is released in the `afterAll` method.

### 6.3 Performance Testing
### 5.3 Performance Testing

Performance testing is in progress.

## 6. CI/CD

- [Build Workflow](https://github.com/taosdata/taos-connector-node/actions/workflows/build.yaml)
- [Code Coverage](https://app.codecov.io/gh/taosdata/taos-connector-node)

## 7. Submitting Issues

We welcome the submission of [GitHub Issue](https://github.com/taosdata/taos-connector-node/issues/new?template=Blank+issue). When submitting, please provide the following information:
Expand All @@ -108,6 +102,7 @@ We welcome developers to contribute to this project. When submitting PRs, please
1. Modify the code, ensure all unit tests pass, and add new unit tests to verify the changes.
1. Push the changes to the remote branch (`git push origin my_branch`).
1. Create a Pull Request on GitHub ([how to create a pull request](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request)).
1. After submitting the PR, you can find your PR through the [Pull Request](https://github.com/taosdata/taos-connector-node/pulls). Click on the corresponding link to see if the CI for your PR has passed. If it has passed, it will display "All checks have passed". Regardless of whether the CI passes or not, you can click "Show all checks" -> "Details" to view the detailed test case logs.
1. After submitting the PR, if CI passes, you can find your PR on the [codecov](https://app.codecov.io/gh/taosdata/taos-connector-node/pulls) page to check the test coverage.

## 9. References
Expand Down

0 comments on commit 0883b9f

Please sign in to comment.