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
-
true
if the scan has been aborted by the user;false
otherwise.Type:
- boolean
- Source:
- See:
Methods
-
abort()
Aborts the query/scan operation.
Once aborted, it is not possible to resume the stream.
-
- Since:
-
- v2.0
- Source:
Events
-
data
-
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.
- Source:
-
end
-
- Source:
-
error
-
Type: AerospikeError
- Source: