Skip to content

Commit 8480836

Browse files
committed
comments
1 parent b4e0db7 commit 8480836

File tree

2 files changed

+64
-110
lines changed

2 files changed

+64
-110
lines changed

README.md

Lines changed: 64 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,68 @@
1+
[npm-image]: https://img.shields.io/npm/v/mysql2.svg
2+
[npm-url]: https://npmjs.com/package/mysql2
3+
[node-version-image]: https://img.shields.io/node/v/mysql2.svg
4+
[node-version-url]: https://nodejs.org/en/download
5+
[downloads-image]: https://img.shields.io/npm/dm/mysql2.svg
6+
[downloads-url]: https://npmjs.com/package/mysql2
7+
[license-url]: https://github.com/sidorares/node-mysql2/blob/master/License
8+
[license-image]: https://img.shields.io/npm/l/mysql2.svg?maxAge=2592000
9+
[node-mysql]: https://github.com/mysqljs/mysql
10+
[mysqljs]: https://github.com/mysqljs
11+
[mysql-native]: https://github.com/sidorares/nodejs-mysql-native
12+
[sidorares]: https://github.com/sidorares
13+
[TooTallNate]: https://gist.github.com/TooTallNate
14+
[starttls.js]: https://gist.github.com/TooTallNate/848444
15+
[node-mariasql]: https://github.com/mscdex/node-mariasql
16+
[contributors]: https://github.com/sidorares/node-mysql2/graphs/contributors
17+
[contributing]: https://github.com/singlestore-labs/singlestore-nodejs/blob/master/Contributing.md
18+
[docs-base]: https://singlestore-labs.github.io/singlestore-nodejs/docs
19+
[docs-api]: https://singlestore-labs.github.io/singlestore-nodejs/docs/api-and-configurations
20+
[docs-prepared-statements]: https://singlestore-labs.github.io/singlestore-nodejs/docs/documentation/prepared-statements
21+
[docs-mysql-server]: https://singlestore-labs.github.io/singlestore-nodejs/docs/documentation/mysql-server
22+
[docs-promise-wrapper]: https://singlestore-labs.github.io/singlestore-nodejs/documentation/promise-wrapper
23+
[docs-authentication-switch]: https://singlestore-labs.github.io/singlestore-nodejs/docs/documentation/authentication-switch
24+
[docs-streams]: https://sidorares.github.io/node-mysql2/docs/documentation/extras
25+
[docs-typescript-docs]: https://sidorares.github.io/node-mysql2/docs/documentation/typescript-examples
26+
[docs-qs-pooling]: https://singlestore-labs.github.io/singlestore-nodejs/docs#using-connection-pools
27+
[docs-qs-first-query]: https://singlestore-labs.github.io/singlestore-nodejs/docs#first-query
28+
[docs-qs-using-prepared-statements]: https://singlestore-labs.github.io/singlestore-nodejs/docs#using-prepared-statements
29+
[docs-examples]: https://singlestore-labs.github.io/singlestore-nodejs/docs/examples
30+
[docs-faq]: https://singlestore-labs.github.io/singlestore-nodejs/docs/faq
31+
[docs-documentation]: https://singlestore-labs.github.io/singlestore-nodejs/docs/documentation
32+
[docs-contributing]: https://singlestore-labs.github.io/singlestore-nodejs/docs/contributing
33+
[tests-image]: https://github.com/singlestore-labs/singlestore-nodejs/actions/workflows/tests.yml/badge.svg?branch=master
34+
[tests-url]: https://github.com/singlestore-labs/singlestore-nodejs/actions/workflows/tests.yml
35+
[gh-pages-image]: https://github.com/singlestore-labs/singlestore-nodejs/actions/workflows/gh-pages.yml/badge.svg?branch=master
36+
[gh-pages-url]: https://github.com/singlestore-labs/singlestore-nodejs/actions/workflows/gh-pages.yml
37+
138
# SingleStore Node.js Driver
239

340
> SingleStore client for Node.js with focus on performance. Supports prepared statements, distributed queries, real-time analytics, compression, ssl and much more.
441
542
[![NPM Version][npm-image]][npm-url]
643
[![NPM Downloads][downloads-image]][downloads-url]
744
[![Node.js Version][node-version-image]][node-version-url]
8-
[![Linux Build][travis-image]][travis-url]
45+
[![Tests][tests-image]][tests-url]
46+
[![GitHub Pages][gh-pages-image]][gh-pages-url]
47+
[![License][license-image]][license-url]
948

1049
## Table of Contents
1150

12-
- [History and Why SingleStore Node.js Driver](#history-and-why-singlestore-nodejs-driver)
51+
- [History and Why MySQL2](#history-and-why-mysql2)
52+
- [Why SingleStore Node.js Driver](#why-singlestore-nodejs-driver)
1353
- [Installation](#installation)
1454
- [Quick Start](#quick-start)
1555
- [Features](#features)
16-
- [Documentation](#documentation)
17-
- [Connection Options](#connection-options)
18-
- [SingleStore-Specific Features](#singlestore-specific-features)
1956
- [Migration from MySQL2](#migration-from-mysql2)
57+
- [Documentation](#documentation)
58+
- [Contributing](#contributing)
59+
- [Acknowledgments](#acknowledgments)
60+
61+
## History and Why MySQL2
62+
63+
MySQL2 project is a continuation of [MySQL-Native][mysql-native]. Protocol parser code was rewritten from scratch and api changed to match popular [Node MySQL][node-mysql]. MySQL2 team is working together with [Node MySQL][node-mysql] team to factor out shared code and move it under [mysqljs][mysqljs] organization.
2064

21-
## History and Why SingleStore Node.js Driver
65+
## Why SingleStore Node.js Driver
2266

2367
The SingleStore Node.js Driver is a fork of MySQL2, adapted specifically for SingleStore database. Since SingleStore is MySQL wire-protocol compatible, most MySQL2 features work seamlessly, with additional optimizations for SingleStore's distributed architecture and analytics capabilities.
2468

@@ -39,6 +83,8 @@ This driver offers these features optimized for SingleStore:
3983
npm install singlestore-nodejs
4084
```
4185

86+
If you are using TypeScript, you will need to install `@types/node`.
87+
4288
## Quick Start
4389

4490
```javascript
@@ -50,7 +96,7 @@ const connection = singlestore.createConnection({
5096
user: 'root',
5197
password: 'password',
5298
database: 'mydb',
53-
port: 3306
99+
port: 3306,
54100
});
55101

56102
// Simple query
@@ -60,7 +106,9 @@ connection.query('SELECT * FROM users', (err, results, fields) => {
60106
});
61107

62108
// Using promises
63-
connection.promise().query('SELECT * FROM products')
109+
connection
110+
.promise()
111+
.query('SELECT * FROM products')
64112
.then(([rows, fields]) => {
65113
console.log(rows);
66114
})
@@ -82,90 +130,6 @@ connection.end();
82130
- **Streaming**: Stream large result sets
83131
- **TypeScript**: Full TypeScript definitions included
84132

85-
## Connection Options
86-
87-
SingleStore Node.js Driver accepts all standard connection options plus SingleStore-specific options:
88-
89-
```javascript
90-
const connection = singlestore.createConnection({
91-
// Standard options
92-
host: 'localhost',
93-
port: 3306,
94-
user: 'root',
95-
password: 'password',
96-
database: 'mydb',
97-
98-
// SingleStore-specific options
99-
enablePipeline: true, // Enable pipeline support
100-
preferAggregator: true, // Prefer aggregator nodes for queries
101-
distributedQuery: true, // Enable distributed query optimizations
102-
columnstoreOptimized: true, // Optimize for columnstore tables
103-
104-
// Performance options
105-
multipleStatements: true,
106-
connectionLimit: 10,
107-
queueLimit: 0,
108-
waitForConnections: true
109-
});
110-
```
111-
112-
## SingleStore-Specific Features
113-
114-
### Pipeline Support
115-
116-
SingleStore pipelines allow for high-throughput data ingestion:
117-
118-
```javascript
119-
// Create a pipeline
120-
connection.query(
121-
`CREATE PIPELINE my_pipeline AS
122-
LOAD DATA S3 'bucket/path'
123-
INTO TABLE my_table`,
124-
(err) => {
125-
if (err) throw err;
126-
// Start the pipeline
127-
connection.query('START PIPELINE my_pipeline');
128-
}
129-
);
130-
```
131-
132-
### Batch Inserts Optimization
133-
134-
Optimized batch inserts for high-throughput scenarios:
135-
136-
```javascript
137-
const values = [
138-
[1, 'John', '[email protected]'],
139-
[2, 'Jane', '[email protected]'],
140-
// ... thousands more rows
141-
];
142-
143-
connection.query(
144-
'INSERT INTO users (id, name, email) VALUES ?',
145-
[values],
146-
(err, result) => {
147-
if (err) throw err;
148-
console.log(`Inserted ${result.affectedRows} rows`);
149-
}
150-
);
151-
```
152-
153-
### Distributed Queries
154-
155-
SingleStore Node.js Driver handles distributed queries efficiently:
156-
157-
```javascript
158-
// Query automatically routed to appropriate nodes
159-
connection.query(
160-
'SELECT COUNT(*) FROM large_table WHERE date > ?',
161-
[new Date('2024-01-01')],
162-
(err, results) => {
163-
if (err) throw err;
164-
console.log(results);
165-
}
166-
);
167-
```
168-
169133
## Migration from MySQL2
170134

171135
SingleStore Node.js Driver is API-compatible with MySQL2, so migration is straightforward:
@@ -181,22 +145,19 @@ const connection = singlestore.createConnection({...});
181145

182146
// All existing queries work as-is!
183147
```
184-
<!-- TODO: Documentation links reference non-existent files. The README references documentation files that don't exist -->
148+
185149
## Documentation
186-
- [Connection Options](documentation/Connection-Options.md)
187-
- [Prepared Statements](documentation/Prepared-Statements.md)
188-
- [Connection Pooling](documentation/Connection-Pooling.md)
189-
- [Promise Wrapper](documentation/Promise-Wrapper.md)
190-
- [API Reference](documentation/API.md)
191-
- [SingleStore Features](documentation/SingleStore-Features.md)
192150

193-
## Contributing
151+
📚 **Full documentation:** [SingleStore Nodejs Driver][docs-base]
194152

195-
Contributions are welcome! Please see [Contributing.md](Contributing.md) for details.
153+
- [Getting Started][docs-documentation]
154+
- [Examples][docs-examples]
155+
- [FAQ][docs-faq]
156+
- [API Reference][docs-api]
196157

197-
## License
158+
## Contributing
198159

199-
MIT License - see [LICENSE](LICENSE)
160+
Contributions are welcome! Please see [Contributing.md](Contributing.md) for details.
200161

201162
## Acknowledgments
202163

website/docs/api-and-configurations.mdx

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
SingleStore Node.js Driver is mostly API compatible with [node-mysql2][node-mysql2] and [Node MySQL][node-mysql]. Since SingleStore is MySQL wire-protocol compatible, most existing MySQL client code works seamlessly.
88

9-
109
## Known Incompatibilities
1110

1211
One known incompatibility is that `DECIMAL` values are returned as strings whereas in [Node MySQL][node-mysql] they are returned as numbers. This includes the result of `SUM()` and `AVG()` functions when applied to `INTEGER` arguments. This is done deliberately to avoid loss of precision - see https://github.com/sidorares/node-mysql2/issues/935.
@@ -30,9 +29,3 @@ const connection = singlestore.createConnection({...});
3029
:::info
3130
If you find any incompatibility with [node-mysql2][node-mysql2] or issues specific to SingleStoreDB, please report via GitHub issue. We will address reported issues on priority basis.
3231
:::
33-
34-
## Additional Resources
35-
36-
- [SingleStoreDB Documentation][singlestore-docs]
37-
- [Connection Options](/docs/documentation/connection-options)
38-
- [SingleStore-Specific Features](/docs/documentation/singlestore-features)

0 commit comments

Comments
 (0)