Skip to content

Commit 53fe729

Browse files
authored
Add result.rowCount information (#75)
* Remove timescale sponsorship * Add note on result.rowCount * Change email address
1 parent 92c0884 commit 53fe729

File tree

4 files changed

+14
-21
lines changed

4 files changed

+14
-21
lines changed

content/api/3-result.mdx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,20 @@ console.log(result.rows) // [ [ 1, 2 ] ]
3333
await client.end()
3434
```
3535

36+
### `result.command: string`
37+
38+
The command type last executed: `INSERT` `UPDATE` `CREATE` `SELECT` etc.
39+
3640
### `result.rowCount: int`
3741

3842
The number of rows processed by the last command.
3943

4044
_note: this does not reflect the number of rows __returned__ from a query. e.g. an update statement could update many rows (so high `result.rowCount` value) but `result.rows.length` would be zero. To check for an empty query reponse on a `SELECT` query use `result.rows.length === 0`_.
4145

42-
### `result.command: string`
46+
[@sehrope](https://github.com/brianc/node-postgres/issues/2182#issuecomment-620553915) has a good explanation:
4347

44-
The command type last executed: `INSERT` `UPDATE` `CREATE` `SELECT` etc.
48+
The `rowCount` is populated from the command tag supplied by the PostgreSQL server. It's generally of the form: `COMMAND [OID] [ROWS]`
49+
50+
For DML commands (INSERT, UPDATE, etc), it reflects how many rows the server modified to process the command. For SELECT or COPY commands it reflects how many rows were retrieved or copied. More info on the specifics here: https://www.postgresql.org/docs/current/protocol-message-formats.html (search for CommandComplete for the message type)
51+
52+
The note in the docs about the difference is because that value is controlled by the server. It's possible for a non-standard server (ex: PostgreSQL fork) or a server version in the future to provide different information in some situations so it'd be best not to rely on it to assume that the rows array length matches the `rowCount`. It's fine to use it for DML counts though.

content/welcome.mdx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@ $ npm install pg
1616
node-postgres continued development and support is made possible by the many [supporters](https://github.com/brianc/node-postgres/blob/master/SPONSORS.md) with a special thanks to our featured supporters:
1717

1818
<div class="sponsors">
19-
<div class="sponsor">
20-
<a href="https://www.timescale.com">
21-
<img src="timescale.svg" style={{ height: 80 }} alt="timescale.com" />
22-
</a>
23-
</div>
2419
<div class="sponsor">
2520
<a href="https://www.crate.io">
2621
<img src="crate-io.png" style={{ height: 80 }} alt="crate.io" />
@@ -29,7 +24,7 @@ node-postgres continued development and support is made possible by the many [su
2924
</div>
3025

3126

32-
If you or your company would like to sponsor node-postgres stop by [github sponsors](https://github.com/sponsors/brianc) and sign up!
27+
If you or your company would like to sponsor node-postgres stop by [github sponsors](https://github.com/sponsors/brianc) and sign up or feel free to [email me](mailto:brian@pecanware.com) if you want to add your logo to the documentation or discuss higher tiers of sponsorship!
3328

3429
## Getting started
3530

src/components/Header.js

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,6 @@ const Header = ({ location }) => (
5353
<Link to="/" className={'navbar-brand navBarBrand'}>
5454
{headerTitle}
5555
</Link>
56-
<div>
57-
<span className="sponsor">
58-
sponsored by{' '}
59-
<a className="sponsor-name" href="https://www.timescale.com">
60-
Timescale
61-
</a>
62-
</span>
63-
</div>
6456
</div>
6557
</div>
6658
<div id="navbar" className={'navbar-collapse collapse navBarCollapse'}>
@@ -102,7 +94,9 @@ const Header = ({ location }) => (
10294
}
10395
})}
10496
<li>
105-
<a href="https://github.com/sponsors/brianc" target="_blank" rel="noreferrer">{'❤️ Sponsor'}</a>
97+
<a href="https://github.com/sponsors/brianc" target="_blank" rel="noreferrer">
98+
{'❤️ Sponsor'}
99+
</a>
106100
</li>
107101
</ul>
108102
</div>

src/components/footer.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,6 @@ export default class Footer extends Component {
3333
@briancarlson
3434
</a>
3535
</span>
36-
<span style={{ margin: 5 }}>|</span>
37-
<span>
38-
sponsored by <a href="https://www.timescale.com">Timescale</a>
39-
</span>
4036
</div>
4137
</div>
4238
)

0 commit comments

Comments
 (0)