OptionalfiltersFilters to apply to the query.
Note: Currently, a single index filter is supported. To do more advanced filtering, you need to use a user-defined function (UDF) to process the result set on the server.
OptionalmaxApproximate number of records to return to client.
When paginate is true, then maxRecords will be the page size if there are enough records remaining in the query to fill the page size.
When paginate is false, this number is divided by the number of nodes involved in the scan, and actual number of records returned may be less than maxRecords if node record counts are small and unbalanced across nodes.
OptionalnobinsIf set to true, the query will return only meta data, and exclude bins.
OptionalpaginateIf set to true, paginated queries are enabled. In order to receive paginated results, the maxRecords property must assign a nonzero integer value.
const Aerospike = require('./lib/aerospike');
// Define host configuration
let config = {
 hosts: '34.213.88.142:3000',
 policies: {
 batchWrite : new Aerospike.BatchWritePolicy({socketTimeout : 0, totalTimeout : 0}),
 }
};
var batchRecords = []
for(let i = 0; i < 30; i++){
 batchRecords.push({
 type: Aerospike.batchType;.BATCH_WRITE,
 key: new Aerospike.Key('test', 'demo', 'key' + i),
 ops:[Aerospike.operations.write('exampleBin', i)]
 })
}
;(async function() {
 try {
 client = await Aerospike.connect(config)
 await client.truncate('test', 'demo', 0)
 await client.batchWrite(batchRecords, {socketTimeout : 0, totalTimeout : 0})
 const query = client.query('test', 'demo', { paginate: true, maxRecords: 10})
 do {
 const stream = query.foreach()
 stream.on('error', (error) => { throw error })
 stream.on('data', (record) => {
 console.log(record.bins)
 })
 await new Promise(resolve => {
 stream.on('end', (queryState) => {
 query.queryState = queryState
 resolve()
 })
 })
 } while (query.queryState !== undefined)
 } catch (error) {
 console.error('An error occurred at some point.', error)
 process.exit(1)
 } finally {
 if (client) client.close()
 }
})() const Aerospike = require('./lib/aerospike');
// Define host configuration
let config = {
 hosts: '34.213.88.142:3000',
 policies: {
 batchWrite : new Aerospike.BatchWritePolicy({socketTimeout : 0, totalTimeout : 0}),
 }
};
var batchRecords = []
for(let i = 0; i < 30; i++){
 batchRecords.push({
 type: Aerospike.batchType.BATCH_WRITE,
 key: new Aerospike.Key('test', 'demo', 'key' + i),
 ops:[Aerospike.operations.write('exampleBin', i)]
 })
}
;(async function() {
 try {
 client = await Aerospike.connect(config)
 await client.truncate('test', 'demo', 0)
 await client.batchWrite(batchRecords, {socketTimeout : 0, totalTimeout : 0})
 const query = client.query('test', 'demo', { paginate: true, maxRecords: 11})
 let allResults = []
 let results = await query.results()
 allResults = [...allResults, ...results]
 results = await query.results()
 allResults = [...allResults, ...results]
 results = await query.results()
 allResults = [...allResults, ...results]
 console.log("Records returned in total: " + allResults.length) // Should be 30 records
 } catch (error) {
 console.error('An error occurred at some point.', error)
 process.exit(1)
 } finally {
 if (client) client.close()
 }
})() OptionalselectList of bin names to be selected by the query. If a query specifies bins to be selected, then only those bins will be returned. If no bins are selected, then all bins will be returned (unless Query#nobins is set to true).
OptionalttlThe time-to-live (expiration) of the record in seconds.
There are also special values that can be set in the record TTL For details
Note that the TTL value will be employed ONLY on background query writes.
OptionaludfUser-defined function parameters to be applied to the query executed using Query#foreach.
Interface used for providing options to a new Query class instance.