Constructor
new RecordStream()
- Source:
Example
const Aerospike = require('aerospike')
// INSERT HOSTNAME AND PORT NUMBER OF AEROSPIKE SERVER NODE HERE!
var config = {
hosts: '192.168.33.10:3000',
// Timeouts disabled, latency dependent on server location. Configure as needed.
policies: {
scan : new Aerospike.ScanPolicy({socketTimeout : 0, totalTimeout : 0}),
}
}
Aerospike.connect(config, (error, client) => {
if (error) throw error
var recordsSeen = 0
var scan = client.scan('test', 'demo')
var stream = scan.foreach()
stream.on('error', (error) => {
console.error(error)
throw error
})
stream.on('data', (record) => {
recordsSeen++
console.log(record)
if (recordsSeen > 1000) {
stream.abort() // We've seen enough!
}
})
stream.on('end', () => {
console.info(stream.aborted ? 'scan aborted' : 'scan completed')
client.close()
})
})
Extends
- stream
Members
aborted :boolean
- Description:
true
if the scan has been aborted by the user;false
otherwise.
- Source:
- See:
true
if the scan has been aborted by the user; false
otherwise.
Type:
- boolean
Methods
abort()
Aborts the query/scan operation.
Once aborted, it is not possible to resume the stream.
- Source:
- Since:
- v2.0
Events
data
- Source:
Parameters:
Name | Type | Description |
---|---|---|
record |
Record | Aerospike record incl. bins, key and meta data. Depending on the operation, all, some or no bin values will be returned. |
end
- Source:
error
- Source: