Skip to content

Commit 6363fb9

Browse files
authored
Merge pull request #10 from happy-game/master
完成打包发布到 npm
2 parents d89c7f2 + 36490bd commit 6363fb9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+119
-103
lines changed

docs/pages/apis/client.mdx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ type Config = {
3434
example to create a client with specific connection information:
3535
3636
```js
37-
import { Client } from 'gaussdb'
37+
import { Client } from 'gaussdb-node'
3838

3939
const client = new Client({
4040
user: 'database-user',
@@ -48,7 +48,7 @@ const client = new Client({
4848
## client.connect
4949

5050
```js
51-
import { Client } from 'gaussdb'
51+
import { Client } from 'gaussdb-node'
5252
const client = new Client()
5353

5454
await client.connect()
@@ -90,7 +90,7 @@ client.query(text: string, values?: any[]) => Promise<Result>
9090
**Plain text query**
9191

9292
```js
93-
import { Client } from 'gaussdb'
93+
import { Client } from 'gaussdb-node'
9494
const client = new Client()
9595

9696
await client.connect()
@@ -104,7 +104,7 @@ await client.end()
104104
**Parameterized query**
105105

106106
```js
107-
import { Client } from 'gaussdb'
107+
import { Client } from 'gaussdb-node'
108108
const client = new Client()
109109

110110
await client.connect()
@@ -142,7 +142,7 @@ await client.end()
142142
If you pass an object to `client.query` and the object has a `.submit` function on it, the client will pass it's GaussDB server connection to the object and delegate query dispatching to the supplied object. This is an advanced feature mostly intended for library authors. It is incidentally also currently how the callback and promise based queries above are handled internally, but this is subject to change. It is also how [gaussdb-cursor](https://github.com/HuaweiCloudDeveloper/gaussdb-node/tree/master/packages/gaussdb-cursor) and [gaussdb-query-stream](https://github.com/HuaweiCloudDeveloper/gaussdb-node/tree/master/packages/gaussdb-query-stream) work.
143143

144144
```js
145-
import { Query } from 'gaussdb'
145+
import { Query } from 'gaussdb-node'
146146
const query = new Query('select $1::text as name', ['brianc'])
147147

148148
const result = client.query(query)

docs/pages/apis/cursor.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ $ npm install gaussdb gaussdb-cursor
1818
Instantiates a new Cursor. A cursor is an instance of `Submittable` and should be passed directly to the `client.query` method.
1919

2020
```js
21-
import { Pool } from 'gaussdb'
21+
import { Pool } from 'gaussdb-node'
2222
import Cursor from 'gaussdb-cursor'
2323

2424
const pool = new Pool()
@@ -55,7 +55,7 @@ If the cursor has read to the end of the result sets all subsequent calls to cur
5555
Here is an example of reading to the end of a cursor:
5656

5757
```js
58-
import { Pool } from 'gaussdb'
58+
import { Pool } from 'gaussdb-node'
5959
import Cursor from 'gaussdb-cursor'
6060

6161
const pool = new Pool()

docs/pages/apis/pool.mdx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ type Config = {
5656
example to create a new pool with configuration:
5757
5858
```js
59-
import { Pool } from 'gaussdb'
59+
import { Pool } from 'gaussdb-node'
6060

6161
const pool = new Pool({
6262
host: 'localhost',
@@ -76,7 +76,7 @@ pool.query(text: string, values?: any[]) => Promise<gaussdb.Result>
7676
```
7777

7878
```js
79-
import { Pool } from 'gaussdb'
79+
import { Pool } from 'gaussdb-node'
8080

8181
const pool = new Pool()
8282

@@ -108,7 +108,7 @@ Acquires a client from the pool.
108108
- If the pool is 'full' and all clients are currently checked out will wait in a FIFO queue until a client becomes available by it being released back to the pool.
109109

110110
```js
111-
import { Pool } from 'gaussdb'
111+
import { Pool } from 'gaussdb-node'
112112

113113
const pool = new Pool()
114114

@@ -126,7 +126,7 @@ Client instances returned from `pool.connect` will have a `release` method which
126126
The `release` method on an acquired client returns it back to the pool. If you pass a truthy value in the `destroy` parameter, instead of releasing the client to the pool, the pool will be instructed to disconnect and destroy this client, leaving a space within itself for a new client.
127127

128128
```js
129-
import { Pool } from 'gaussdb'
129+
import { Pool } from 'gaussdb-node'
130130

131131
const pool = new Pool()
132132

@@ -138,7 +138,7 @@ client.release()
138138
```
139139

140140
```js
141-
import { Pool } from 'gaussdb'
141+
import { Pool } from 'gaussdb-node'
142142

143143
const pool = new Pool()
144144
assert(pool.totalCount === 0)
@@ -171,7 +171,7 @@ Calling `pool.end` will drain the pool of all active clients, disconnect them, a
171171

172172
```js
173173
// again both promises and callbacks are supported:
174-
import { Pool } from 'gaussdb'
174+
import { Pool } from 'gaussdb-node'
175175

176176
const pool = new Pool()
177177

docs/pages/apis/result.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Every result will have a rows array. If no rows are returned the array will be e
1818
Every result will have a fields array. This array contains the `name` and `dataTypeID` of each field in the result. These fields are ordered in the same order as the columns if you are using `arrayMode` for the query:
1919

2020
```js
21-
import gaussdb from 'gaussdb'
21+
import gaussdb from 'gaussdb-node'
2222
const { Pool } = gaussdb
2323

2424
const pool = new Pool()

docs/pages/apis/utilities.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { Alert } from '/components/alert.tsx'
99
Escapes a string as a [SQL identifier](https://www.gaussdb.org/docs/current/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS).
1010

1111
```js
12-
import { escapeIdentifier } from 'gaussdb';
12+
import { escapeIdentifier } from 'gaussdb-node';
1313
const escapedIdentifier = escapeIdentifier('FooIdentifier')
1414
console.log(escapedIdentifier) // '"FooIdentifier"'
1515
```
@@ -27,7 +27,7 @@ console.log(escapedIdentifier) // '"FooIdentifier"'
2727
Escapes a string as a [SQL literal](https://www.gaussdb.org/docs/current/sql-syntax-lexical.html#SQL-SYNTAX-CONSTANTS).
2828

2929
```js
30-
import { escapeLiteral } from 'gaussdb';
30+
import { escapeLiteral } from 'gaussdb-node';
3131
const escapedLiteral = escapeLiteral("hello 'world'")
3232
console.log(escapedLiteral) // "'hello ''world'''"
3333
```

docs/pages/features/callbacks.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ title: Callbacks
88

99

1010
```js
11-
const { Pool, Client } = require('gaussdb')
11+
const { Pool, Client } = require('gaussdb-node')
1212

1313
// pool
1414
const pool = new Pool()

docs/pages/features/connecting.mdx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Both individual clients & pools will use these environment variables. Here's a t
99
Both individual clients & pools will use these environment variables. Here's a tiny program connecting node.js to the GaussDB server:
1010

1111
```js
12-
import gaussdb from 'gaussdb'
12+
import gaussdb from 'gaussdb-node'
1313
const { Pool, Client } = gaussdb
1414

1515
// pools will use environment variables
@@ -57,7 +57,7 @@ GAUSSDB_DATABASE=process.env.USER (fallback to GAUSSDATABASE)
5757
gaussdb-node also supports configuring a pool or client programmatically with connection information. Here's our same script from above modified to use programmatic (hard-coded in this case) values. This can be useful if your application already has a way to manage config values or you don't want to use environment variables.
5858

5959
```js
60-
import gaussdb from 'gaussdb'
60+
import gaussdb from 'gaussdb-node'
6161
const { Pool, Client } = gaussdb
6262

6363
const pool = new Pool({
@@ -88,7 +88,7 @@ await client.end()
8888
Many cloud providers include alternative methods for connecting to database instances using short-lived authentication tokens. gaussdb-node supports dynamic passwords via a callback function, either synchronous or asynchronous. The callback function must resolve to a string.
8989

9090
```js
91-
import gaussdb from 'gaussdb'
91+
import gaussdb from 'gaussdb-node'
9292
const { Pool } = gaussdb
9393
import { RDS } from 'aws-sdk'
9494

@@ -121,7 +121,7 @@ const pool = new Pool({
121121
Connections to unix sockets can also be made. This can be useful on distros like Ubuntu, where authentication is managed via the socket connection instead of a password.
122122

123123
```js
124-
import gaussdb from 'gaussdb'
124+
import gaussdb from 'gaussdb-node'
125125
const { Client } = gaussdb
126126
client = new Client({
127127
user: 'username',
@@ -136,7 +136,7 @@ client = new Client({
136136
You can initialize both a pool and a client with a connection string URI as well. This is common in environments like Heroku where the database connection string is supplied to your application dyno through an environment variable. Connection string parsing brought to you by [gaussdb-connection-string](https://github.com/HuaweiCloudDeveloper/gaussdb-node/tree/master/packages/gaussdb-connection-string).
137137

138138
```js
139-
import gaussdb from 'gaussdb'
139+
import gaussdb from 'gaussdb-node'
140140
const { Pool, Client } = gaussdb
141141
const connectionString = 'gaussdb://dbuser:[email protected]:3211/mydb'
142142

docs/pages/features/esm.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: ESM
44

55
## ESM Support
66

7-
As of v8.15.x gaussdb-node supporters the __ECMAScript Module__ (ESM) format. This means you can use `import` statements instead of `require` or `import gaussdb from 'gaussdb'`.
7+
As of v8.15.x gaussdb-node supporters the __ECMAScript Module__ (ESM) format. This means you can use `import` statements instead of `require` or `import gaussdb from 'gaussdb-node'`.
88

99
CommonJS modules are still supported. The ESM format is an opt-in feature and will not affect existing codebases that use CommonJS.
1010

@@ -13,7 +13,7 @@ The docs have been changed to show ESM usage, but in a CommonJS context you can
1313
If you're using CommonJS, you can use the following code to import the `gaussdb` module:
1414

1515
```js
16-
const gaussdb = require('gaussdb')
16+
const gaussdb = require('gaussdb-node')
1717
const { Client } = gaussdb
1818
// etc...
1919
```
@@ -23,15 +23,15 @@ If you're using CommonJS, you can use the following code to import the `gaussdb`
2323
If you're using ESM, you can use the following code to import the `gaussdb` module:
2424

2525
```js
26-
import { Client } from 'gaussdb'
26+
import { Client } from 'gaussdb-node'
2727
// etc...
2828
```
2929

3030

3131
Previously if you were using ESM you would have to use the following code:
3232

3333
```js
34-
import gaussdb from 'gaussdb'
34+
import gaussdb from 'gaussdb-node'
3535
const { Client } = gaussdb
3636
// etc...
3737
```

docs/pages/features/native.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ $ npm install gaussdb pg-native
1515
Once `pg-native` is installed instead of requiring a `Client` or `Pool` constructor from `gaussdb` you do the following:
1616

1717
```js
18-
import gaussdb from 'gaussdb'
18+
import gaussdb from 'gaussdb-node'
1919
const { native } = gaussdb
2020
const { Client, Pool } = native
2121
```
2222

23-
When you access the `.native` property on `'gaussdb'` it will automatically require the `pg-native` package and wrap it in the same API.
23+
When you access the `.native` property on `'gaussdb-node'` it will automatically require the `pg-native` package and wrap it in the same API.
2424

2525
<div class='alert alert-warning'>
2626
Care has been taken to normalize between the two, but there might still be edge cases where things behave subtly differently due to the nature of using libpq over handling the binary protocol directly in JavaScript, so it's recommended you chose to either use the JavaScript driver or the native bindings both in development and production. For what its worth: I use the pure JavaScript driver because the JavaScript driver is more portable (doesn't need a compiler), and the pure JavaScript driver is <em>plenty</em> fast.

docs/pages/features/pooling.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ The client pool allows you to have a reusable pool of clients you can check out,
2828
### Checkout, use, and return
2929

3030
```js
31-
import gaussdb from 'gaussdb'
31+
import gaussdb from 'gaussdb-node'
3232
const { Pool } = gaussdb
3333

3434
const pool = new Pool()
@@ -61,7 +61,7 @@ client.release()
6161
If you don't need a transaction or you just need to run a single query, the pool has a convenience method to run a query on any available client in the pool. This is the preferred way to query with gaussdb-node if you can as it removes the risk of leaking a client.
6262

6363
```js
64-
import gaussdb from 'gaussdb'
64+
import gaussdb from 'gaussdb-node'
6565
const { Pool } = gaussdb
6666

6767
const pool = new Pool()
@@ -75,7 +75,7 @@ console.log('user:', res.rows[0])
7575
To shut down a pool call `pool.end()` on the pool. This will wait for all checked-out clients to be returned and then shut down all the clients and the pool timers.
7676

7777
```js
78-
import gaussdb from 'gaussdb'
78+
import gaussdb from 'gaussdb-node'
7979
const { Pool } = gaussdb
8080
const pool = new Pool()
8181

0 commit comments

Comments
 (0)