Skip to content

Commit

Permalink
Merge pull request #1699 from tmonoceros/master
Browse files Browse the repository at this point in the history
Clarify timing requirements of streaming events in README
  • Loading branch information
dhensby authored Sep 7, 2024
2 parents 0c29da8 + 2d7c6b0 commit ee28c61
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ sql.on('error', err => {

### Streaming

If you plan to work with large amount of rows, you should always use streaming. Once you enable this, you must listen for events to receive data.
If you plan to work with large amount of rows, you should always use streaming. Once you enable this, you must listen for events to receive data. Events must be attached before the query completes, but can be attached while in-flight.

```javascript
const sql = require('mssql')
Expand All @@ -361,7 +361,6 @@ sql.connect(config, err => {

const request = new sql.Request()
request.stream = true // You can set streaming differently for each request
request.query('select * from verylargetable') // or request.execute(procedure)

request.on('recordset', columns => {
// Emitted once for each recordset in a query
Expand All @@ -383,6 +382,8 @@ sql.connect(config, err => {
request.on('done', result => {
// Always emitted as the last one
})

request.query('select * from verylargetable') // or request.execute(procedure)
})

sql.on('error', err => {
Expand Down

0 comments on commit ee28c61

Please sign in to comment.