Socket
Socket
Sign inDemoInstall

aerospike

Package Overview
Dependencies
244
Maintainers
5
Versions
135
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 5.10.0 to 5.11.0

examples/typescript.ts

8

lib/policies/batch_write_policy.js

@@ -39,3 +39,11 @@ // *****************************************************************************

this.filterExpression = props.filterExpression
/**
* The time-to-live (expiration) of the record in seconds.
*
* @type number
*/
this.ttl = props.ttl
/**
* Specifies the behavior for the key.

@@ -42,0 +50,0 @@ *

3

lib/policy.js

@@ -63,3 +63,3 @@ // *****************************************************************************

* deprecated {@link Client#batchExists}, {@link Client#batchGet}, and {@link
* Client#batchSelect} operations.
* Client#batchSelect} operations. Also used when providing batchParentWrite policy to a client configuration.
* * {@link BatchApplyPolicy} - Applies to {@link Client#batchApply}.

@@ -447,2 +447,3 @@ * * {@link BatchReadPolicy} - Applies to {@link Client#batchRead}.

case 'batchWrite': return BatchWritePolicy
case 'batchParentWrite': return BatchPolicy
case 'batchApply': return BatchApplyPolicy

@@ -449,0 +450,0 @@ case 'commandQueue': return CommandQueuePolicy

@@ -28,2 +28,33 @@ // *****************************************************************************

/**
* One or more keys failed in a batch.
* @const {number}
*/
exports.BATCH_FAILED = exports.AEROSPIKE_BATCH_FAILED = as.status.AEROSPIKE_BATCH_FAILED
/**
* No response received from server.
* @const {number}
*/
exports.NO_RESPONSE = exports.AEROSPIKE_NO_RESPONSE = as.status.AEROSPIKE_NO_RESPONSE
/**
* Max errors limit reached.
* @const {number}
*/
exports.MAX_ERROR_RATE = exports.AEROSPIKE_MAX_ERROR_RATE = as.status.AEROSPIKE_MAX_ERROR_RATE
/**
* Abort split batch retry and use normal node retry instead.
* Used internally and should not be returned to user.
* @const {number}
*/
exports.USE_NORMAL_RETRY = exports.AEROSPIKE_USE_NORMAL_RETRY = as.status.AEROSPIKE_USE_NORMAL_RETRY
/**
* Max retries limit reached.
* @const {number}
*/
exports.ERR_MAX_RETRIES_EXCEEDED = exports.AEROSPIKE_ERR_MAX_RETRIES_EXCEEDED = as.status.AEROSPIKE_ERR_MAX_RETRIES_EXCEEDED
/**
* Async command delay queue is full.

@@ -30,0 +61,0 @@ * @const {number}

@@ -232,2 +232,4 @@ // *****************************************************************************

* @property {BatchPolicy} batch - Default batch policy
* @property {BatchPolicy} batchWrite - Default write policy used in batch operate commands. Contains a {@link BatchWritePolicy}.
* @property {BatchPolicy} batchParentWrite - Default parent policy used in batch write commands. Contains a {@link BatchPolicy}.
* @property {InfoPolicy} info - Default info policy

@@ -234,0 +236,0 @@ * @property {OperatePolicy} operate - Default operate policy

{
"name": "aerospike",
"version": "5.10.0",
"version": "5.11.0",
"description": "Aerospike Client Library",

@@ -45,2 +45,3 @@ "keywords": [

"test": "mocha",
"test-dry-run": "mocha --dry-run",
"test-noserver": "GLOBAL_CLIENT=false mocha -g '#noserver'",

@@ -62,8 +63,8 @@ "lint": "standard",

"minimatch": "^3.1.2",
"nan": "^2.17.0",
"node-gyp": "^8.4.1",
"nan": "^2.18.0",
"node-gyp": "^10.0.1",
"npm-run-all": "^4.1.5"
},
"devDependencies": {
"@types/node": "^17.0.45",
"@types/node": "^20.11.18",
"chai": "^4.3.7",

@@ -73,12 +74,11 @@ "choma": "^1.2.1",

"deep-eql": "^4.1.3",
"dirty-chai": "^2.0.1",
"husky": "^7.0.4",
"mocha": "^9.2.2",
"husky": "^9.0.11",
"mocha": "^10.3.0",
"mocha-clean": "^1.0.0",
"nyc": "^15.1.0",
"p-throttle": "^3.1.0",
"semver": "^7.5.4",
"standard": "^16.0.4",
"tmp": "^0.1.0",
"yargs": "^15.4.1"
"semver": "^7.6.0",
"standard": "^17.1.0",
"tmp": "^0.2.1",
"yargs": "^17.7.2"
},

@@ -85,0 +85,0 @@ "standard": {

@@ -191,2 +191,6 @@ # Aerospike Node.js Client [![travis][travis-image]][travis-url] [![codecov][codecov-image]][codecov-url] [![npm][npm-image]][npm-url] [![downloads][downloads-image]][downloads-url]

### Windows
See our [Windows README.md](https://github.com/aerospike/aerospike-client-nodejs/blob/master/README_WINDOWS.md) for details on how to build and install on windows.
### macOS

@@ -193,0 +197,0 @@

@@ -23,3 +23,2 @@ // *****************************************************************************

const helper = require('./test_helper')
const options = require('./util/options')

@@ -444,3 +443,3 @@ function getRandomInt (max) {

} catch (error) {
expect(error).to.exist().and.have.property('code', Aerospike.status.INVALID_ROLE)
expect(error).to.exist.and.have.property('code', Aerospike.status.INVALID_ROLE)
}

@@ -457,3 +456,3 @@ })

} catch (error) {
expect(error).to.exist().and.have.property('code', Aerospike.status.INVALID_ROLE)
expect(error).to.exist.and.have.property('code', Aerospike.status.INVALID_ROLE)
}

@@ -466,4 +465,5 @@ })

client.changePassword(username1, 'password350', null)
await wait(waitMs + 30000)
const config = {
hosts: options.host + ':' + options.port,
hosts: helper.config.hosts,
user: username1,

@@ -473,3 +473,3 @@ password: 'password350'

const dummyClient = await Aerospike.connect(config)
dummyClient.close()
return dummyClient.close()
})

@@ -479,9 +479,12 @@

client.changePassword(username2, 'password250', policy)
await wait(waitMs + 3000)
const config = {
hosts: options.host + ':' + options.port,
hosts: helper.config.hosts,
user: username2,
password: 'password250'
}
const dummyClient = await Aerospike.connect(config)
dummyClient.close()
return dummyClient.close()
})

@@ -499,3 +502,3 @@ })

} catch (error) {
expect(error).to.exist().and.have.property('code', Aerospike.status.INVALID_USER)
expect(error).to.exist.and.have.property('code', Aerospike.status.INVALID_USER)
}

@@ -511,3 +514,3 @@ })

} catch (error) {
expect(error).to.exist().and.have.property('code', Aerospike.status.INVALID_USER)
expect(error).to.exist.and.have.property('code', Aerospike.status.INVALID_USER)
}

@@ -514,0 +517,0 @@ })

@@ -21,2 +21,3 @@ // *****************************************************************************

/* global expect */
/* eslint-disable no-unused-expressions */

@@ -76,3 +77,3 @@ const Aerospike = require('../lib/aerospike')

client.batchApply(batchRecords, udf, policy, function (err, results) {
expect(err).not.to.be.ok()
expect(err).not.to.be.ok
expect(results.length).to.equal(5)

@@ -79,0 +80,0 @@ results.forEach(function (result) {

@@ -20,2 +20,3 @@ // *****************************************************************************

/* global expect, describe, it */
/* eslint-disable no-unused-expressions */

@@ -61,3 +62,3 @@ const Aerospike = require('../lib/aerospike')

client.batchExists(keys, function (err, results) {
expect(err).not.to.be.ok()
expect(err).not.to.be.ok
expect(results.length).to.equal(numberOfRecords)

@@ -64,0 +65,0 @@ results.forEach(function (result) {

@@ -20,2 +20,3 @@ // *****************************************************************************

/* global expect, describe, it */
/* eslint-disable no-unused-expressions */

@@ -61,3 +62,3 @@ const Aerospike = require('../lib/aerospike')

client.batchGet(keys, function (err, results) {
expect(err).not.to.be.ok()
expect(err).not.to.be.ok
expect(results.length).to.equal(numberOfRecords)

@@ -64,0 +65,0 @@ results.forEach(function (result) {

@@ -21,2 +21,3 @@ // *****************************************************************************

/* global expect */
/* eslint-disable no-unused-expressions */

@@ -62,3 +63,3 @@ const Aerospike = require('../lib/aerospike')

client.batchRead(batchRecords, function (err, results) {
expect(err).not.to.be.ok()
expect(err).not.to.be.ok
expect(results.length).to.equal(5)

@@ -83,7 +84,7 @@ const found = results.filter(

client.batchRead(batchRecords, function (err, results) {
expect(err).not.to.be.ok()
expect(err).not.to.be.ok
expect(results.length).to.equal(3)
results.forEach(function (result) {
expect(result.status).to.equal(Aerospike.status.OK)
expect(result.record.bins).to.be.empty()
expect(result.record.bins).to.be.empty
})

@@ -102,3 +103,3 @@ done()

client.batchRead(batchRecords, function (err, results) {
expect(err).not.to.be.ok()
expect(err).not.to.be.ok
expect(results.length).to.equal(3)

@@ -108,4 +109,4 @@ results.forEach(function (result) {

expect(result.record.bins).to.have.all.keys('i')
expect(result.record.gen).to.be.ok()
expect(result.record.ttl).to.be.ok()
expect(result.record.gen).to.be.ok
expect(result.record.ttl).to.be.ok
})

@@ -124,3 +125,3 @@ done()

client.batchRead(batchRecords, function (err, results) {
expect(err).not.to.be.ok()
expect(err).not.to.be.ok
expect(results.length).to.equal(3)

@@ -130,4 +131,4 @@ results.forEach(function (result) {

expect(result.record.bins).to.have.keys('i', 's', 'l', 'm')
expect(result.record.gen).to.be.ok()
expect(result.record.ttl).to.be.ok()
expect(result.record.gen).to.be.ok
expect(result.record.ttl).to.be.ok
})

@@ -146,3 +147,3 @@ done()

client.batchRead(batchRecords, function (err, results) {
expect(err).not.to.be.ok()
expect(err).not.to.be.ok
expect(results.length).to.equal(3)

@@ -159,3 +160,3 @@ results.forEach(function (result) {

case 'test/batch_read/5':
expect(record.bins).to.be.empty()
expect(record.bins).to.be.empty
break

@@ -162,0 +163,0 @@ default:

@@ -21,2 +21,3 @@ // *****************************************************************************

/* global expect */
/* eslint-disable no-unused-expressions */

@@ -66,3 +67,3 @@ const Aerospike = require('../lib/aerospike')

client.batchRemove(batchRecords, function (err, results) {
expect(err).not.to.be.ok()
expect(err).not.to.be.ok
expect(results.length).to.equal(5)

@@ -69,0 +70,0 @@ results.forEach(function (result) {

@@ -20,2 +20,3 @@ // *****************************************************************************

/* global expect, describe, it */
/* eslint-disable no-unused-expressions */

@@ -61,3 +62,3 @@ const Aerospike = require('../lib/aerospike')

client.batchSelect(keys, bins, function (err, results) {
expect(err).not.to.be.ok()
expect(err).not.to.be.ok
expect(results.length).to.equal(numberOfRecords)

@@ -64,0 +65,0 @@ results.forEach(function (result) {

@@ -21,2 +21,4 @@ // *****************************************************************************

/* global expect */
/* eslint-disable no-unused-expressions */
const Aerospike = require('../lib/aerospike')

@@ -43,3 +45,3 @@ const helper = require('./test_helper')

before(function () {
const nrecords = 17
const nrecords = 20
const generators = {

@@ -94,3 +96,3 @@ keygen: keygen.string(helper.namespace, helper.set, { prefix: 'test/batch_write/', random: false }),

result => result.status === Aerospike.status.ERR_RECORD_NOT_FOUND)
expect(err).not.to.be.ok()
expect(err).not.to.be.ok
expect(results.length).to.equal(5)

@@ -138,11 +140,11 @@ expect(found.length).to.equal(3 - inDoubt.length)

client.batchWrite(batchWriteRecords, function (err, results) {
expect(err).to.be.null()
expect(err).to.be.null
expect(results.length).to.equal(2)
expect(results[1].record.bins).to.be.empty()
expect(results[1].record.bins).to.be.empty
client.batchWrite(batchReadRecords, function (err, results) {
expect(err).not.to.be.ok()
expect(err).not.to.be.ok
expect(results.length).to.equal(3)
expect(results[0].record.bins).to.have.all.keys('i', 's', 'l', 'm', 'str2', 'geo', 'blob', 'string')
expect(results[1].status).to.equal(Aerospike.status.ERR_RECORD_NOT_FOUND)
expect(results[2].record.bins).to.be.empty()
expect(results[2].record.bins).to.be.empty
// results.forEach(function (result) {

@@ -223,3 +225,3 @@ // console.log(util.inspect(result, true, 10, true))

client.batchWrite(batchRecords, function (error, results) {
expect(error).not.to.be.ok()
expect(error).not.to.be.ok
expect(results[0].status).to.equal(status.OK)

@@ -283,3 +285,3 @@ done()

client.batchWrite(batchRecords, function (error, results) {
expect(error).not.to.be.ok()
expect(error).not.to.be.ok
expect(results[0].status).to.equal(status.ERR_RECORD_EXISTS)

@@ -364,3 +366,3 @@ done()

client.batchWrite(batchRecords, function (error, results) {
expect(error).not.to.be.ok()
expect(error).not.to.be.ok
expect(results[0].status).to.equal(status.ERR_RECORD_NOT_FOUND)

@@ -424,3 +426,3 @@ done()

client.batchWrite(batchRecords, function (error, results) {
expect(error).not.to.be.ok()
expect(error).not.to.be.ok
expect(results[0].status).to.equal(status.ERR_RECORD_NOT_FOUND)

@@ -484,3 +486,3 @@ done()

client.batchWrite(batchRecords, function (error, results) {
expect(error).not.to.be.ok()
expect(error).not.to.be.ok
expect(results[0].status).to.equal(status.OK)

@@ -521,2 +523,57 @@ done()

})
context('with BatchParentWritePolicy', function () {
helper.skipUnlessVersion('>= 6.0.0', this)
this.timeout(10000)
it('returns list and map bins as byte buffers', async function () {
const batch = [{
type: batchType.BATCH_READ,
key: new Key(helper.namespace, helper.set, 'test/batch_write/18'),
readAllBins: true
}]
const config = {
hosts: helper.config.hosts,
policies: {
batchParentWrite: new Aerospike.BatchPolicy({ socketTimeout: 0, totalTimeout: 0, deserialize: false })
}
}
const dummyClient = await Aerospike.connect(config)
const results = await dummyClient.batchWrite(batch)
const bins = results[0].record.bins
expect(bins.i).to.be.a('number')
expect(bins.s).to.be.a('string')
expect(bins.l).to.be.instanceof(Buffer)
expect(bins.m).to.be.instanceof(Buffer)
await dummyClient.close()
})
})
context('with BatchWritePolicy ttl', function () {
helper.skipUnlessVersion('>= 6.0.0', this)
it('writes value with correct ttl', async function () {
const batch = [{
type: batchType.BATCH_WRITE,
key: new Key(helper.namespace, helper.set, 'test/batch_write/19'),
ops: [
op.write('example', 35),
op.write('blob', [4, 14, 28])
],
policy: new Aerospike.BatchWritePolicy({
exists: Aerospike.policy.exists.REPLACE,
ttl: 1367
})
}]
await client.batchWrite(batch)
return client.get(new Key(helper.namespace, helper.set, 'test/batch_write/19'))
.then(results => {
const bins = results.bins
expect(bins.example).to.be.a('number')
expect(bins.blob).to.be.a('array')
expect(results.ttl).to.equal(1367)
})
})
})
})

@@ -20,2 +20,3 @@ // *****************************************************************************

/* global context, expect, describe, it */
/* eslint-disable no-unused-expressions */

@@ -44,3 +45,3 @@ const Aerospike = require('../lib/aerospike')

if (error) throw error
expect(async).to.be.true()
expect(async).to.be.true
client.close(false)

@@ -73,3 +74,3 @@ done()

client.connect(error => {
expect(error).to.be.null()
expect(error).to.be.null
client.close(false)

@@ -105,3 +106,3 @@ client.close(false)

const client = new Client(helper.config)
expect(client.isConnected(false)).to.be.false()
expect(client.isConnected(false)).to.be.false
})

@@ -112,3 +113,3 @@

client.connect(function () {
expect(client.isConnected(false)).to.be.true()
expect(client.isConnected(false)).to.be.true
client.close(false)

@@ -123,3 +124,3 @@ done()

client.close(false)
expect(client.isConnected(false)).to.be.false()
expect(client.isConnected(false)).to.be.false
done()

@@ -137,4 +138,4 @@ })

client.as_client.isConnected = function () { tenderHealthCheck = true; return false }
expect(client.isConnected(true)).to.be.false()
expect(tenderHealthCheck).to.be.true()
expect(client.isConnected(true)).to.be.false
expect(tenderHealthCheck).to.be.true
client.as_client.isConnected = orig

@@ -141,0 +142,0 @@ client.close(false)

@@ -20,2 +20,3 @@ // *****************************************************************************

/* global beforeEach, afterEach, expect, describe, it */
/* eslint-disable no-unused-expressions */

@@ -157,3 +158,3 @@ const Aerospike = require('../lib/aerospike')

expect(config).to.not.have.property('rackId')
expect(config.policies).to.be.empty()
expect(config.policies).to.be.empty
})

@@ -160,0 +161,0 @@

@@ -20,3 +20,3 @@ // *****************************************************************************

/* global expect, it, context */
/* eslint-disable no-unused-expressions */
const helper = require('./test_helper')

@@ -64,5 +64,5 @@

await client.remove(key, policy)
expect(await client.exists(key)).to.be.false()
expect(await client.exists(key)).to.be.false
})
})
})

@@ -20,2 +20,3 @@ // *****************************************************************************

/* global expect, describe, it */
/* eslint-disable no-unused-expressions */

@@ -111,7 +112,7 @@ const AerospikeError = require('../lib/error')

const error = { code: status.OK }
expect(AerospikeError.fromASError(error)).to.be.null()
expect(AerospikeError.fromASError(error)).to.be.null
})
it('returns null if no error is passed', function () {
expect(AerospikeError.fromASError(null)).to.be.null()
expect(AerospikeError.fromASError(null)).to.be.null
})

@@ -124,3 +125,3 @@ })

const subject = AerospikeError.fromASError(error)
expect(subject.isServerError()).to.be.true()
expect(subject.isServerError()).to.be.true
})

@@ -131,3 +132,3 @@

const subject = AerospikeError.fromASError(error)
expect(subject.isServerError()).to.be.false()
expect(subject.isServerError()).to.be.false
})

@@ -134,0 +135,0 @@ })

@@ -20,2 +20,3 @@ // *****************************************************************************

/* global context, expect, describe, it */
/* eslint-disable no-unused-expressions */

@@ -34,3 +35,3 @@ const helper = require('./test_helper')

.then(() => client.exists(key))
.then(result => expect(result).to.be.true())
.then(result => expect(result).to.be.true)
.then(() => client.remove(key))

@@ -43,3 +44,3 @@ })

return client.exists(key)
.then(result => expect(result).to.be.false())
.then(result => expect(result).to.be.false)
})

@@ -56,3 +57,3 @@ })

if (error) throw error
expect(result).to.be.true()
expect(result).to.be.true
client.remove(key, error => {

@@ -71,3 +72,3 @@ if (error) throw error

if (error) throw error
expect(result).to.be.false()
expect(result).to.be.false
done()

@@ -74,0 +75,0 @@ })

@@ -723,3 +723,2 @@ // *****************************************************************************

result = await client.get(key)
console.log(result)
expect(result.bins).to.eql({ tags: { a: 'blue', c: 'yellow' } })

@@ -742,3 +741,2 @@ })

result = await client.get(key)
console.log(result)
expect(result.bins).to.eql({ tags: { a: 'blue', nested: { d: 'orange', f: 'white', g: 'black' } } })

@@ -745,0 +743,0 @@ })

@@ -99,2 +99,3 @@ // *****************************************************************************

describe('eq on map bin', function () {
helper.skipUnlessVersion('>= 6.3.0', this)
it('evaluates to true if a map bin matches a value', async function () {

@@ -116,2 +117,3 @@ const key = await createRecord({ map: { c: 1, b: 2, a: 3 } })

describe('eq on list bin', function () {
helper.skipUnlessVersion('>= 6.3.0', this)
it('evaluates to true if a list bin matches a value', async function () {

@@ -118,0 +120,0 @@ const key = await createRecord({ list: [4, 2, 0] })

@@ -20,2 +20,3 @@ // *****************************************************************************

/* global expect, beforeEach, afterEach, describe, it */
/* eslint-disable no-unused-expressions */

@@ -49,3 +50,3 @@ const Aerospike = require('../lib/aerospike')

job.waitUntilDone(10, function (err) {
expect(err).to.not.be.ok()
expect(err).to.not.be.ok
done()

@@ -73,3 +74,3 @@ })

return job.checkStatus()
.then(status => expect(status).to.be.false())
.then(status => expect(status).to.be.false)
})

@@ -76,0 +77,0 @@

@@ -213,4 +213,4 @@ // *****************************************************************************

describe('Client#indexRemove()', async function () {
beforeEach(() => {
helper.index.create(testIndex.name, helper.set, testIndex.bin,
beforeEach(async () => {
await helper.index.create(testIndex.name, helper.set, testIndex.bin,
Aerospike.indexDataType.STRING, Aerospike.indexType.DEFAULT)

@@ -244,6 +244,6 @@ })

it('should return a Promise if called without callback function', function () {
return client.indexRemove(helper.namespace, testIndex.name)
it('should return a Promise if called without callback function', async function () {
return await client.indexRemove(helper.namespace, testIndex.name)
})
})
})

@@ -20,2 +20,3 @@ // *****************************************************************************

/* global expect, describe, it, context, before */
/* eslint-disable no-unused-expressions */

@@ -108,3 +109,3 @@ const Aerospike = require('../lib/aerospike')

client.infoAny('status', function (err, result) {
expect(err).to.not.be.ok()
expect(err).to.not.be.ok
expect(result).to.equal('status\tok\n')

@@ -126,6 +127,6 @@ done()

client.infoAll('status', function (err, results) {
expect(err).to.not.be.ok()
expect(Array.isArray(results)).to.be.true()
expect(err).to.not.be.ok
expect(Array.isArray(results)).to.be.true
results.forEach(function (result) {
expect(result.host).to.be.ok()
expect(result.host).to.be.ok
expect(result.info).to.equal('status\tok\n')

@@ -140,3 +141,3 @@ })

.then(results =>
expect(Array.isArray(results)).to.be.true())
expect(Array.isArray(results)).to.be.true)
})

@@ -147,5 +148,5 @@

.then(results => {
expect(Array.isArray(results)).to.be.true()
expect(Array.isArray(results)).to.be.true
results.forEach(result => {
expect(result.host).to.be.ok()
expect(result.host).to.be.ok
expect(result.info).to.equal('status\tok\n')

@@ -152,0 +153,0 @@ })

@@ -20,2 +20,3 @@ // *****************************************************************************

/* global expect, describe, context, it */
/* eslint-disable no-unused-expressions */

@@ -56,7 +57,7 @@ const Aerospike = require('../lib/aerospike')

it('allows null set name', function () {
expect(new Key('ns', null, 'key')).to.be.ok()
expect(new Key('ns', null, 'key')).to.be.ok
})
it('allows undefined set name', function () {
expect(new Key('ns', undefined, 'key')).to.be.ok()
expect(new Key('ns', undefined, 'key')).to.be.ok
})

@@ -81,12 +82,12 @@

it('allows string user key', function () {
expect(new Key('ns', 'set', 'abc')).to.be.ok()
expect(new Key('ns', 'set', 'abc')).to.be.ok
})
it('allows string user key of arbitrary length', function () {
expect(new Key('ns', 'set', 'abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789')).to.be.ok()
expect(new Key('ns', 'set', 'abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789')).to.be.ok
})
it('allows integer user key', function () {
expect(new Key('ns', 'set', 1234)).to.be.ok()
expect(new Key('ns', 'set', -1234)).to.be.ok()
expect(new Key('ns', 'set', 1234)).to.be.ok
expect(new Key('ns', 'set', -1234)).to.be.ok
})

@@ -98,5 +99,5 @@

it('allows BigInt user key', function () {
expect(new Key('ns', 'set', BigInt(42))).to.be.ok()
expect(new Key('ns', 'set', BigInt(2) ** BigInt(63) - BigInt(1))).to.be.ok()
expect(new Key('ns', 'set', BigInt(-2) ** BigInt(63))).to.be.ok()
expect(new Key('ns', 'set', BigInt(42))).to.be.ok
expect(new Key('ns', 'set', BigInt(2) ** BigInt(63) - BigInt(1))).to.be.ok
expect(new Key('ns', 'set', BigInt(-2) ** BigInt(63))).to.be.ok
})

@@ -112,11 +113,11 @@

const buf = Buffer.from([0x62, 0x75, 0x66, 0x66, 0x65, 0x72])
expect(new Key('ns', 'set', buf)).to.be.ok()
expect(new Key('ns', 'set', buf)).to.be.ok
})
it('allows undefined user key', function () {
expect(new Key('ns', 'set', undefined, dummyDigest)).to.be.ok()
expect(new Key('ns', 'set', undefined, dummyDigest)).to.be.ok
})
it('allows null user key', function () {
expect(new Key('ns', 'set', null, dummyDigest)).to.be.ok()
expect(new Key('ns', 'set', null, dummyDigest)).to.be.ok
})

@@ -148,3 +149,3 @@

const digest = Buffer.from([0x15, 0xc7, 0x49, 0xfd, 0x01, 0x54, 0x43, 0x8b, 0xa9, 0xd9, 0x5d, 0x0c, 0x6e, 0x27, 0x0f, 0x1a, 0x76, 0xfc, 0x31, 0x15])
expect(new Key('ns', null, null, digest)).to.be.ok()
expect(new Key('ns', null, null, digest)).to.be.ok
})

@@ -166,4 +167,4 @@

const key2 = new Key('ns1', 'set1', 'key1')
expect(key1.equals(key2)).to.be.true()
expect(key2.equals(key1)).to.be.true()
expect(key1.equals(key2)).to.be.true
expect(key2.equals(key1)).to.be.true
})

@@ -174,4 +175,4 @@

const key2 = new Key('ns1', 'set1', 'key1', Buffer.from('a1b2c3d4e5f6g7h8i9j0'))
expect(key1.equals(key2)).to.be.true()
expect(key2.equals(key1)).to.be.true()
expect(key1.equals(key2)).to.be.true
expect(key2.equals(key1)).to.be.true
})

@@ -182,4 +183,4 @@

const key2 = new Key('ns1', 'set1', null, Buffer.from('a1b2c3d4e5f6g7h8i9j0'))
expect(key1.equals(key2)).to.be.true()
expect(key2.equals(key1)).to.be.true()
expect(key1.equals(key2)).to.be.true
expect(key2.equals(key1)).to.be.true
})

@@ -190,4 +191,4 @@

const key2 = new Key('ns1', 'set1', 'key1')
expect(key1.equals(key2)).to.be.true()
expect(key2.equals(key1)).to.be.true()
expect(key1.equals(key2)).to.be.true
expect(key2.equals(key1)).to.be.true
})

@@ -198,4 +199,4 @@

const key2 = new Key('ns1', null, 'key1')
expect(key1.equals(key2)).to.be.true()
expect(key2.equals(key1)).to.be.true()
expect(key1.equals(key2)).to.be.true
expect(key2.equals(key1)).to.be.true
})

@@ -206,4 +207,4 @@

const key2 = new Key('ns2', 'set1', 'key1')
expect(key1.equals(key2)).to.be.false()
expect(key2.equals(key1)).to.be.false()
expect(key1.equals(key2)).to.be.false
expect(key2.equals(key1)).to.be.false
})

@@ -214,4 +215,4 @@

const key2 = new Key('ns1', 'set2', 'key1')
expect(key1.equals(key2)).to.be.false()
expect(key2.equals(key1)).to.be.false()
expect(key1.equals(key2)).to.be.false
expect(key2.equals(key1)).to.be.false
})

@@ -222,4 +223,4 @@

const key2 = new Key('ns1', null, 'key1')
expect(key1.equals(key2)).to.be.false()
expect(key2.equals(key1)).to.be.false()
expect(key1.equals(key2)).to.be.false
expect(key2.equals(key1)).to.be.false
})

@@ -230,4 +231,4 @@

const key2 = new Key('ns1', 'set1', 'key2')
expect(key1.equals(key2)).to.be.false()
expect(key2.equals(key1)).to.be.false()
expect(key1.equals(key2)).to.be.false
expect(key2.equals(key1)).to.be.false
})

@@ -238,4 +239,4 @@

const key2 = new Key('ns1', 'set1', null, Buffer.from('a1b2c3d4e5f6g7h8i9j0'))
expect(key1.equals(key2)).to.be.false()
expect(key2.equals(key1)).to.be.false()
expect(key1.equals(key2)).to.be.false
expect(key2.equals(key1)).to.be.false
})

@@ -246,4 +247,4 @@

const key2 = new Key('ns1', 'set1', 'key1', Buffer.from('0j9i8h7g6f5e4d3c2b1a'))
expect(key1.equals(key2)).to.be.false()
expect(key2.equals(key1)).to.be.false()
expect(key1.equals(key2)).to.be.false
expect(key2.equals(key1)).to.be.false
})

@@ -259,3 +260,3 @@ })

client.put(key, { foo: 'bar' }, function (err) {
expect(err).to.not.be.ok()
expect(err).to.not.be.ok
done()

@@ -262,0 +263,0 @@ })

@@ -21,2 +21,3 @@ // *****************************************************************************

/* global expect */
/* eslint-disable no-unused-expressions */

@@ -845,2 +846,64 @@ const Aerospike = require('../lib/aerospike')

describe('lists.create', function () {
it('creates a new list', function () {
return initState()
.then(createRecord({ list: [1, 2, 3, 4, 5] }))
.then(operate(lists.create('emptyList', lists.order.ORDERED)))
.then(assertRecordEql({ list: [1, 2, 3, 4, 5], emptyList: [] }))
.then(cleanup)
})
it('creates a new list with persist index true', function () {
return initState()
.then(createRecord({ list: [1, 2, 3, 4, 5] }))
.then(operate(lists.create('emptyList', lists.order.ORDERED, false, true)))
.then(assertRecordEql({ list: [1, 2, 3, 4, 5], emptyList: [] }))
.then(cleanup)
})
it('creates a new list with persist index true and pad true', function () {
return initState()
.then(createRecord({ list: [1, 2, 3, 4, 5] }))
.then(operate(lists.create('emptyList', lists.order.ORDERED, true, true)))
.then(assertRecordEql({ list: [1, 2, 3, 4, 5], emptyList: [] }))
.then(cleanup)
})
it('creates a new list with pad true', function () {
return initState()
.then(createRecord({ list: [1, 2, 3, 4, 5] }))
.then(operate(lists.create('emptyList', lists.order.ORDERED, true, false)))
.then(assertRecordEql({ list: [1, 2, 3, 4, 5], emptyList: [] }))
.then(cleanup)
})
context('with nested list context', function () {
helper.skipUnlessVersion('>= 4.6.0', this)
it('creates a new list within a map', function () {
return initState()
.then(createRecord({ map: { c: 1, b: 2, a: 3 } }))
.then(operate(lists.create('map', lists.order.ORDERED).withContext(ctx => ctx.addMapKeyCreate('nested'))))
.then(assertRecordEql({ map: { c: 1, b: 2, a: 3, nested: [] } }))
.then(cleanup)
})
it('creates a new list within a list', function () {
return initState()
.then(createRecord({ list: [1, 2, 3, 4, 5] }))
.then(operate(lists.create('list', lists.order.UNORDERED, true, false).withContext(ctx => ctx.addListIndex(10))))
.then(assertRecordEql({ list: [1, 2, 3, 4, 5, null, null, null, null, null, []] }))
.then(cleanup)
})
it('creates a new list within a list', function () {
return initState()
.then(createRecord({ list: [1, 2, 3, 4, 5] }))
.then(operate(lists.create('list', lists.order.UNORDERED, true, true).withContext(ctx => ctx.addListIndex(10))))
.then(assertRecordEql({ list: [1, 2, 3, 4, 5, null, null, null, null, null, []] }))
.then(cleanup)
})
})
})
describe('lists.set', function () {

@@ -1109,2 +1172,3 @@ it('sets the item at the specified index', function () {

context('returnType=EXISTS', function () {
helper.skipUnlessVersion('>= 6.1.0', this)
it('fetches all items with the specified values and returns the indexes', function () {

@@ -1111,0 +1175,0 @@ return initState()

@@ -300,3 +300,2 @@ // *****************************************************************************

it('adds each item from the Map class to the map and returns the size of the map', function () {
console.log(maps.putItems('map', new Map([['e', 150], ['d', 100], ['c', 99]])))
return initState()

@@ -1559,56 +1558,65 @@ .then(createRecord({ map: { a: 1, b: 2, c: 3 } }))

it('returns true or false for a single key read', function () {
return initState()
.then(createRecord({ map: { a: 1, b: 2, c: 3 } }))
.then(orderByKey('map'))
.then(operate(maps.getByKeyList('map', ['a', 'b', 'd'], maps.returnType.EXISTS)))
.then(assertResultEql({ map: true }))
.then(cleanup())
})
context('returnType.EXISTS', function () {
helper.skipUnlessVersion('>= 6.1.0', this)
it('returns true or false for a single key read', function () {
return initState()
.then(createRecord({ map: { a: 1, b: 2, c: 3 } }))
.then(orderByKey('map'))
.then(operate(maps.getByKeyList('map', ['a', 'b', 'd'], maps.returnType.EXISTS)))
.then(assertResultEql({ map: true }))
.then(cleanup())
})
it('returns true if any values exisst', function () {
return initState()
.then(createRecord({ map: { a: 1, b: 2, c: 3 } }))
.then(orderByKey('map'))
.then(operate(maps.getByValueList('map', [1, 2, 4], maps.returnType.EXISTS)))
.then(assertResultEql({ map: true }))
.then(cleanup())
it('returns true if any values exist', function () {
return initState()
.then(createRecord({ map: { a: 1, b: 2, c: 3 } }))
.then(orderByKey('map'))
.then(operate(maps.getByValueList('map', [1, 2, 4], maps.returnType.EXISTS)))
.then(assertResultEql({ map: true }))
.then(cleanup())
})
})
it('returns key/value for a single read', function () {
return initState()
.then(createRecord({ map: { a: 1, b: 2, c: 3 } }))
.then(orderByKey('map'))
.then(operate(maps.getByIndex('map', 0, maps.returnType.ORDERED_MAP)))
.then(assertResultEql({ map: { a: 1 } }))
.then(cleanup())
})
context('returnType.ORDERED_MAP', function () {
helper.skipUnlessVersion('>= 6.3.0', this)
it('returns key/value for a single read', function () {
return initState()
.then(createRecord({ map: { a: 1, b: 2, c: 3 } }))
.then(orderByKey('map'))
.then(operate(maps.getByIndex('map', 0, maps.returnType.ORDERED_MAP)))
.then(assertResultEql({ map: { a: 1 } }))
.then(cleanup())
})
it('returns key/value for a range read', function () {
return initState()
.then(createRecord({ map: { a: 1, b: 2, c: 3 } }))
.then(orderByKey('map'))
.then(operate(maps.getByIndexRange('map', 0, 2, maps.returnType.ORDERED_MAP)))
.then(assertResultEql({ map: { a: 1, b: 2 } }))
.then(cleanup())
it('returns key/value for a range read', function () {
return initState()
.then(createRecord({ map: { a: 1, b: 2, c: 3 } }))
.then(orderByKey('map'))
.then(operate(maps.getByIndexRange('map', 0, 2, maps.returnType.ORDERED_MAP)))
.then(assertResultEql({ map: { a: 1, b: 2 } }))
.then(cleanup())
})
})
it('returns key/value for a single read', function () {
return initState()
.then(createRecord({ map: { a: 1, b: 2, c: 3 } }))
.then(orderByKey('map'))
.then(operate(maps.getByIndex('map', 0, maps.returnType.UNORDERED_MAP)))
.then(assertResultEql({ map: { a: 1 } }))
.then(cleanup())
})
context('returnType.UNORDERED_MAP', function () {
helper.skipUnlessVersion('>= 6.3.0', this)
it('returns key/value for a single read', function () {
return initState()
.then(createRecord({ map: { a: 1, b: 2, c: 3 } }))
.then(orderByKey('map'))
.then(operate(maps.getByIndex('map', 0, maps.returnType.UNORDERED_MAP)))
.then(assertResultEql({ map: { a: 1 } }))
.then(cleanup())
})
it('returns key/value for a range read', function () {
return initState()
.then(createRecord({ map: { a: 1, b: 2, c: 3 } }))
.then(orderByKey('map'))
.then(operate(maps.getByIndexRange('map', 0, 2, maps.returnType.UNORDERED_MAP)))
.then(assertResultEql({ map: { a: 1, b: 2 } }))
.then(cleanup())
it('returns key/value for a range read', function () {
return initState()
.then(createRecord({ map: { a: 1, b: 2, c: 3 } }))
.then(orderByKey('map'))
.then(operate(maps.getByIndexRange('map', 0, 2, maps.returnType.UNORDERED_MAP)))
.then(assertResultEql({ map: { a: 1, b: 2 } }))
.then(cleanup())
})
})
})
})

@@ -21,2 +21,3 @@ // *****************************************************************************

/* global expect */
/* eslint-disable no-unused-expressions */

@@ -87,3 +88,3 @@ const Aerospike = require('../lib/aerospike')

)
expect(record.bins.blob.equals(Buffer.from('bar'))).to.be.ok()
expect(record.bins.blob.equals(Buffer.from('bar'))).to.be.ok
expect(record.bins.list).to.eql([2, 3, 4])

@@ -280,3 +281,3 @@ expect(record.bins.map).to.eql({ d: 4, e: 5, f: 6 })

.then(() => client.exists(notExistentKey))
.then(exists => expect(exists).to.be.false())
.then(exists => expect(exists).to.be.false)
})

@@ -283,0 +284,0 @@ })

@@ -21,2 +21,3 @@ // *****************************************************************************

/* global expect */
/* eslint-disable no-unused-expressions */

@@ -41,3 +42,3 @@ const Aerospike = require('../lib/aerospike')

expect(subject.maxRetries).to.equal(2)
expect(subject.compress).to.be.true()
expect(subject.compress).to.be.true
})

@@ -66,3 +67,3 @@ })

expect(subject.ttl).to.equal(3600)
expect(subject.durableDelete).to.be.true()
expect(subject.durableDelete).to.be.true
})

@@ -95,3 +96,3 @@ })

expect(subject.commitLevel).to.equal(2)
expect(subject.durableDelete).to.be.true()
expect(subject.durableDelete).to.be.true
})

@@ -143,4 +144,4 @@ })

expect(subject.readModeSC).to.equal(Aerospike.policy.readModeSC.SESSION)
expect(subject.allowInline).to.be.false()
expect(subject.sendSetName).to.be.true()
expect(subject.allowInline).to.be.false
expect(subject.sendSetName).to.be.true
})

@@ -160,4 +161,4 @@ })

expect(subject.timeout).to.equal(1000)
expect(subject.sendAsIs).to.be.true()
expect(subject.checkBounds).to.be.false()
expect(subject.sendAsIs).to.be.true
expect(subject.checkBounds).to.be.false
})

@@ -188,3 +189,3 @@ })

expect(subject.commitLevel).to.equal(2)
expect(subject.durableDelete).to.be.true()
expect(subject.durableDelete).to.be.true
})

@@ -218,3 +219,3 @@ })

expect(subject.commitLevel).to.equal(2)
expect(subject.durableDelete).to.be.true()
expect(subject.durableDelete).to.be.true
})

@@ -238,3 +239,3 @@ })

expect(subject.maxRetries).to.equal(1)
expect(subject.durableDelete).to.be.true()
expect(subject.durableDelete).to.be.true
expect(subject.recordsPerSecond).to.equal(100)

@@ -241,0 +242,0 @@ })

@@ -580,3 +580,3 @@ // *****************************************************************************

.then(() => client.exists(key))
.then(exists => expect(exists).to.be.false())
.then(exists => expect(exists).to.be.false)
})

@@ -583,0 +583,0 @@ })

@@ -21,2 +21,3 @@ // *****************************************************************************

/* global expect */
/* eslint-disable no-unused-expressions */

@@ -48,2 +49,3 @@ const Aerospike = require('../lib/aerospike')

const putgen = helper.putgen
let samples

@@ -54,3 +56,3 @@ describe('Queries', function () {

const testSet = 'test/query-' + Math.floor(Math.random() * 100000)
const samples = [
samples = [
{ name: 'int match', i: 5 },

@@ -88,33 +90,3 @@ { name: 'int non-match', i: 500 },

{ name: 'filter', value: 3 },
{ name: 'filter', value: 4 },
{ name: 'nested int list match', li: { nested: [1, 5, 9] } },
{ name: 'nested int list non-match', li: { nested: [500, 501, 502] } },
{ name: 'nested int map match', mi: { nested: { a: 1, b: 5, c: 9 } } },
{ name: 'nested int map non-match', mi: { nested: { a: 500, b: 501, c: 502 } } },
{ name: 'nested string list match', ls: { nested: ['banana', 'blueberry'] } },
{ name: 'nested string list non-match', ls: { nested: ['tomato', 'cuccumber'] } },
{ name: 'nested string map match', ms: { nested: { a: 'banana', b: 'blueberry' } } },
{ name: 'nested string map non-match', ms: { nested: { a: 'tomato', b: 'cuccumber' } } },
{ name: 'nested string mapkeys match', mks: { nested: { banana: 1, blueberry: 2 } } },
{ name: 'nested string mapkeys non-match', mks: { nested: { tomato: 3, cuccumber: 4 } } },
{ name: 'nested point match', g: { nested: GeoJSON.Point(103.913, 1.308) } },
{ name: 'nested point non-match', g: { nested: GeoJSON.Point(-122.101, 37.421) } },
{ name: 'nested point list match', lg: { nested: [GeoJSON.Point(103.913, 1.308), GeoJSON.Point(105.913, 3.308)] } },
{ name: 'nested point list non-match', lg: { nested: [GeoJSON.Point(-122.101, 37.421), GeoJSON.Point(-120.101, 39.421)] } },
{ name: 'nested point map match', mg: { nested: { a: GeoJSON.Point(103.913, 1.308), b: GeoJSON.Point(105.913, 3.308) } } },
{ name: 'nested point map non-match', mg: { nested: { a: GeoJSON.Point(-122.101, 37.421), b: GeoJSON.Point(-120.101, 39.421) } } },
{ name: 'nested region match', g: { nested: GeoJSON.Polygon([102.913, 0.308], [102.913, 2.308], [104.913, 2.308], [104.913, 0.308], [102.913, 0.308]) } },
{ name: 'nested region non-match', g: { nested: GeoJSON.Polygon([-121.101, 36.421], [-121.101, 38.421], [-123.101, 38.421], [-123.101, 36.421], [-121.101, 36.421]) } },
{ name: 'nested region list match', lg: { nested: [GeoJSON.Polygon([102.913, 0.308], [102.913, 2.308], [104.913, 2.308], [104.913, 0.308], [102.913, 0.308])] } },
{ name: 'nested region list non-match', lg: { nested: [GeoJSON.Polygon([-121.101, 36.421], [-121.101, 38.421], [-123.101, 38.421], [-123.101, 36.421], [-121.101, 36.421])] } },
{ name: 'nested region map match', mg: { nested: { a: GeoJSON.Polygon([102.913, 0.308], [102.913, 2.308], [104.913, 2.308], [104.913, 0.308], [102.913, 0.308]) } } },
{ name: 'nested region map non-match', mg: { nested: [GeoJSON.Polygon([-121.101, 36.421], [-121.101, 38.421], [-123.101, 38.421], [-123.101, 36.421], [-121.101, 36.421])] } },
{ name: 'nested aggregate', nested: { value: 10 } },
{ name: 'nested aggregate', nested: { value: 20 } },
{ name: 'nested aggregate', nested: { value: 30 } },
{ name: 'nested aggregate', nested: { doubleNested: { value: 10 } } },
{ name: 'nested aggregate', nested: { doubleNested: { value: 20 } } },
{ name: 'nested aggregate', nested: { doubleNested: { value: 30 } } }
{ name: 'filter', value: 4 }
]

@@ -133,15 +105,4 @@

['qidxGeoList', 'lg', GEO2DSPHERE, LIST],
['qidxGeoMap', 'mg', GEO2DSPHERE, MAPVALUES],
// CDT context indexes
['qidxNameNested', 'name', STRING, MAPKEYS, new Context().addMapKey('nested')],
['qidxIntListNested', 'li', NUMERIC, LIST, new Context().addMapKey('nested')],
['qidxIntMapNested', 'mi', NUMERIC, MAPVALUES, new Context().addMapKey('nested')],
['qidxStrListNested', 'ls', STRING, LIST, new Context().addMapKey('nested')],
['qidxStrMapNested', 'ms', STRING, MAPVALUES, new Context().addMapKey('nested')],
['qidxStrMapKeysNested', 'mks', STRING, MAPKEYS, new Context().addMapKey('nested')],
['qidxGeoListNested', 'lg', GEO2DSPHERE, LIST, new Context().addMapKey('nested')],
['qidxGeoMapNested', 'mg', GEO2DSPHERE, MAPVALUES, new Context().addMapKey('nested')],
['qidxGeoMap', 'mg', GEO2DSPHERE, MAPVALUES]
['qidxAggregateMapNested', 'nested', STRING, MAPKEYS],
['qidxAggregateMapDoubleNested', 'nested', STRING, MAPKEYS, new Context().addMapKey('doubleNested')]
]

@@ -199,2 +160,45 @@

}
if (helper.cluster.isVersionInRange('>= 6.1.0')) {
samples.push({ name: 'nested int list match', li: { nested: [1, 5, 9] } })
samples.push({ name: 'nested int list non-match', li: { nested: [500, 501, 502] } })
samples.push({ name: 'nested int map match', mi: { nested: { a: 1, b: 5, c: 9 } } })
samples.push({ name: 'nested int map non-match', mi: { nested: { a: 500, b: 501, c: 502 } } })
samples.push({ name: 'nested string list match', ls: { nested: ['banana', 'blueberry'] } })
samples.push({ name: 'nested string list non-match', ls: { nested: ['tomato', 'cuccumber'] } })
samples.push({ name: 'nested string map match', ms: { nested: { a: 'banana', b: 'blueberry' } } })
samples.push({ name: 'nested string map non-match', ms: { nested: { a: 'tomato', b: 'cuccumber' } } })
samples.push({ name: 'nested string mapkeys match', mks: { nested: { banana: 1, blueberry: 2 } } })
samples.push({ name: 'nested string mapkeys non-match', mks: { nested: { tomato: 3, cuccumber: 4 } } })
samples.push({ name: 'nested point match', g: { nested: GeoJSON.Point(103.913, 1.308) } })
samples.push({ name: 'nested point non-match', g: { nested: GeoJSON.Point(-122.101, 37.421) } })
samples.push({ name: 'nested point list match', lg: { nested: [GeoJSON.Point(103.913, 1.308), GeoJSON.Point(105.913, 3.308)] } })
samples.push({ name: 'nested point list non-match', lg: { nested: [GeoJSON.Point(-122.101, 37.421), GeoJSON.Point(-120.101, 39.421)] } })
samples.push({ name: 'nested point map match', mg: { nested: { a: GeoJSON.Point(103.913, 1.308), b: GeoJSON.Point(105.913, 3.308) } } })
samples.push({ name: 'nested point map non-match', mg: { nested: { a: GeoJSON.Point(-122.101, 37.421), b: GeoJSON.Point(-120.101, 39.421) } } })
samples.push({ name: 'nested region match', g: { nested: GeoJSON.Polygon([102.913, 0.308], [102.913, 2.308], [104.913, 2.308], [104.913, 0.308], [102.913, 0.308]) } })
samples.push({ name: 'nested region non-match', g: { nested: GeoJSON.Polygon([-121.101, 36.421], [-121.101, 38.421], [-123.101, 38.421], [-123.101, 36.421], [-121.101, 36.421]) } })
samples.push({ name: 'nested region list match', lg: { nested: [GeoJSON.Polygon([102.913, 0.308], [102.913, 2.308], [104.913, 2.308], [104.913, 0.308], [102.913, 0.308])] } })
samples.push({ name: 'nested region list non-match', lg: { nested: [GeoJSON.Polygon([-121.101, 36.421], [-121.101, 38.421], [-123.101, 38.421], [-123.101, 36.421], [-121.101, 36.421])] } })
samples.push({ name: 'nested region map match', mg: { nested: { a: GeoJSON.Polygon([102.913, 0.308], [102.913, 2.308], [104.913, 2.308], [104.913, 0.308], [102.913, 0.308]) } } })
samples.push({ name: 'nested region map non-match', mg: { nested: [GeoJSON.Polygon([-121.101, 36.421], [-121.101, 38.421], [-123.101, 38.421], [-123.101, 36.421], [-121.101, 36.421])] } })
samples.push({ name: 'nested aggregate', nested: { value: 10 } })
samples.push({ name: 'nested aggregate', nested: { value: 20 } })
samples.push({ name: 'nested aggregate', nested: { value: 30 } })
samples.push({ name: 'nested aggregate', nested: { doubleNested: { value: 10 } } })
samples.push({ name: 'nested aggregate', nested: { doubleNested: { value: 20 } } })
samples.push({ name: 'nested aggregate', nested: { doubleNested: { value: 30 } } })
indexes.push(['qidxNameNested', 'name', STRING, MAPKEYS, new Context().addMapKey('nested')])
indexes.push(['qidxIntListNested', 'li', NUMERIC, LIST, new Context().addMapKey('nested')])
indexes.push(['qidxIntMapNested', 'mi', NUMERIC, MAPVALUES, new Context().addMapKey('nested')])
indexes.push(['qidxStrListNested', 'ls', STRING, LIST, new Context().addMapKey('nested')])
indexes.push(['qidxStrMapNested', 'ms', STRING, MAPVALUES, new Context().addMapKey('nested')])
indexes.push(['qidxStrMapKeysNested', 'mks', STRING, MAPKEYS, new Context().addMapKey('nested')])
indexes.push(['qidxGeoListNested', 'lg', GEO2DSPHERE, LIST, new Context().addMapKey('nested')])
indexes.push(['qidxGeoMapNested', 'mg', GEO2DSPHERE, MAPVALUES, new Context().addMapKey('nested')])
indexes.push(['qidxAggregateMapNested', 'nested', STRING, MAPKEYS])
indexes.push(['qidxAggregateMapDoubleNested', 'nested', STRING, MAPKEYS, new Context().addMapKey('doubleNested')])
}
const numberOfSamples = samples.length

@@ -229,3 +233,3 @@ return Promise.all([

expect(query.selected).to.eql(['a', 'b', 'c'])
expect(query.nobins).to.be.false()
expect(query.nobins).to.be.false
expect(query.filters).to.be.instanceof(Array)

@@ -240,3 +244,3 @@ expect(query.filters.length).to.equal(1)

expect(query.ns).to.equal(helper.namespace)
expect(query.set).to.be.null()
expect(query.set).to.be.null
expect(query.selected).to.eql(['i'])

@@ -276,3 +280,3 @@ })

stream.on('end', () => {
expect(results.length).to.be.above(60)
expect(results.length).to.be.above(samples.length)
done()

@@ -296,3 +300,3 @@ })

expect(query.hasNextPage()).to.equal(false)
expect(recordTotal).to.be.above(60)
expect(recordTotal).to.be.above(samples.length)
break

@@ -320,15 +324,18 @@ }

it('should apply a stream UDF to the nested context', function (done) {
const args = {
filters: [filter.contains('name', 'value', MAPKEYS, new Context().addMapKey('nested'))]
}
const query = client.query(helper.namespace, testSet, args)
query.setUdf('udf', 'even')
const stream = query.foreach()
const results = []
stream.on('error', error => { throw error })
stream.on('data', record => results.push(record.bins))
stream.on('end', () => {
expect(results.sort()).to.eql([])
done()
describe('index with cdt context', function () {
helper.skipUnlessVersion('>= 6.1.0', this)
it('should apply a stream UDF to the nested context', function (done) {
const args = {
filters: [filter.contains('name', 'value', MAPKEYS, new Context().addMapKey('nested'))]
}
const query = client.query(helper.namespace, testSet, args)
query.setUdf('udf', 'even')
const stream = query.foreach()
const results = []
stream.on('error', error => { throw error })
stream.on('data', record => results.push(record.bins))
stream.on('end', () => {
expect(results.sort()).to.eql([])
done()
})
})

@@ -428,25 +435,27 @@ })

})
it('Paginates correctly using query.results() on an index with a cdt context', async function () {
let recordTotal = 0
let recordsReceived = 0
let pageTotal = 0
const lastPage = 1
const maxRecs = 5
const query = client.query(helper.namespace, testSet, { paginate: true, maxRecords: maxRecs, filters: [filter.contains('nested', 'value', MAPKEYS, new Context().addMapKey('doubleNested'))] })
let results = []
while (1) {
results = await query.results()
recordsReceived += results.length
results = []
pageTotal += 1
recordTotal += recordsReceived
if (recordsReceived !== maxRecs) {
expect(query.hasNextPage()).to.equal(false)
expect(pageTotal).to.equal(lastPage)
expect(recordTotal).to.equal(3)
break
describe('index with cdt context', function () {
helper.skipUnlessVersion('>= 6.1.0', this)
it('Paginates correctly using query.results() on an index with a cdt context', async function () {
let recordTotal = 0
let recordsReceived = 0
let pageTotal = 0
const lastPage = 1
const maxRecs = 5
const query = client.query(helper.namespace, testSet, { paginate: true, maxRecords: maxRecs, filters: [filter.contains('nested', 'value', MAPKEYS, new Context().addMapKey('doubleNested'))] })
let results = []
while (1) {
results = await query.results()
recordsReceived += results.length
results = []
pageTotal += 1
recordTotal += recordsReceived
if (recordsReceived !== maxRecs) {
expect(query.hasNextPage()).to.equal(false)
expect(pageTotal).to.equal(lastPage)
expect(recordTotal).to.equal(3)
break
}
recordsReceived = 0
}
recordsReceived = 0
}
})
})

@@ -559,5 +568,5 @@

stream.on('end', () => {
expect(received.bins).to.be.empty()
expect(received.gen).to.be.ok()
expect(received.ttl).to.be.ok()
expect(received.bins).to.be.empty
expect(received.gen).to.be.ok
expect(received.ttl).to.be.ok
done()

@@ -579,5 +588,5 @@ })

stream.on('end', () => {
expect(received.bins).to.be.empty()
expect(received.gen).to.be.ok()
expect(received.ttl).to.be.ok()
expect(received.bins).to.be.empty
expect(received.gen).to.be.ok
expect(received.ttl).to.be.ok
done()

@@ -611,3 +620,3 @@ })

() => {
expect(dataHandlerCalled).to.be.true()
expect(dataHandlerCalled).to.be.true
done()

@@ -652,5 +661,8 @@ })

it('should match integers in a list within a range in a nested context', function (done) {
const args = { filters: [filter.range('li', 3, 7, LIST, new Context().addMapKey('nested'))] }
verifyQueryResults(args, 'nested int list match', done)
describe('index with cdt context', function () {
helper.skipUnlessVersion('>= 6.1.0', this)
it('should match integers in a list within a range in a nested context', function (done) {
const args = { filters: [filter.range('li', 3, 7, LIST, new Context().addMapKey('nested'))] }
verifyQueryResults(args, 'nested int list match', done)
})
})

@@ -663,5 +675,8 @@

it('should match integers in a map within a range in a nested context', function (done) {
const args = { filters: [filter.range('mi', 3, 7, MAPVALUES, new Context().addMapKey('nested'))] }
verifyQueryResults(args, 'nested int map match', done)
describe('index with cdt context', function () {
helper.skipUnlessVersion('>= 6.1.0', this)
it('should match integers in a map within a range in a nested context', function (done) {
const args = { filters: [filter.range('mi', 3, 7, MAPVALUES, new Context().addMapKey('nested'))] }
verifyQueryResults(args, 'nested int map match', done)
})
})

@@ -676,5 +691,8 @@ })

it('should match lists containing an integer in a nested context', function (done) {
const args = { filters: [filter.contains('li', 5, LIST, new Context().addMapKey('nested'))] }
verifyQueryResults(args, 'nested int list match', done)
describe('index with cdt context', function () {
helper.skipUnlessVersion('>= 6.1.0', this)
it('should match lists containing an integer in a nested context', function (done) {
const args = { filters: [filter.contains('li', 5, LIST, new Context().addMapKey('nested'))] }
verifyQueryResults(args, 'nested int list match', done)
})
})

@@ -687,5 +705,8 @@

it('should match maps containing an integer value in a nested context', function (done) {
const args = { filters: [filter.contains('mi', 5, MAPVALUES, new Context().addMapKey('nested'))] }
verifyQueryResults(args, 'nested int map match', done)
describe('index with cdt context', function () {
helper.skipUnlessVersion('>= 6.1.0', this)
it('should match maps containing an integer value in a nested context', function (done) {
const args = { filters: [filter.contains('mi', 5, MAPVALUES, new Context().addMapKey('nested'))] }
verifyQueryResults(args, 'nested int map match', done)
})
})

@@ -698,5 +719,8 @@

it('should match lists containing a string in a nested context', function (done) {
const args = { filters: [filter.contains('ls', 'banana', LIST, new Context().addMapKey('nested'))] }
verifyQueryResults(args, 'nested string list match', done)
describe('index with cdt context', function () {
helper.skipUnlessVersion('>= 6.1.0', this)
it('should match lists containing a string in a nested context', function (done) {
const args = { filters: [filter.contains('ls', 'banana', LIST, new Context().addMapKey('nested'))] }
verifyQueryResults(args, 'nested string list match', done)
})
})

@@ -709,5 +733,8 @@

it('should match maps containing a string value in a nested context', function (done) {
const args = { filters: [filter.contains('ms', 'banana', MAPVALUES, new Context().addMapKey('nested'))] }
verifyQueryResults(args, 'nested string map match', done)
describe('index with cdt context', function () {
helper.skipUnlessVersion('>= 6.1.0', this)
it('should match maps containing a string value in a nested context', function (done) {
const args = { filters: [filter.contains('ms', 'banana', MAPVALUES, new Context().addMapKey('nested'))] }
verifyQueryResults(args, 'nested string map match', done)
})
})

@@ -720,6 +747,10 @@

it('should match maps containing a string key in a nested context', function (done) {
const args = { filters: [filter.contains('mks', 'banana', MAPKEYS, new Context().addMapKey('nested'))] }
verifyQueryResults(args, 'nested string mapkeys match', done)
describe('index with cdt context', function () {
helper.skipUnlessVersion('>= 6.1.0', this)
it('should match maps containing a string key in a nested context', function (done) {
const args = { filters: [filter.contains('mks', 'banana', MAPKEYS, new Context().addMapKey('nested'))] }
verifyQueryResults(args, 'nested string mapkeys match', done)
})
})
context('Uses blob Secondary indexes', function () {

@@ -776,6 +807,9 @@ helper.skipUnlessVersion('>= 7.0.0', this)

it('should match locations in a list within a GeoJSON region in a nested context', function (done) {
const region = new GeoJSON({ type: 'Polygon', coordinates: [[[103, 1.3], [104, 1.3], [104, 1.4], [103, 1.4], [103, 1.3]]] })
const args = { filters: [filter.geoWithinGeoJSONRegion('lg', region, LIST, new Context().addMapKey('nested'))] }
verifyQueryResults(args, 'nested point list match', done)
describe('index with cdt context', function () {
helper.skipUnlessVersion('>= 6.1.0', this)
it('should match locations in a list within a GeoJSON region in a nested context', function (done) {
const region = new GeoJSON({ type: 'Polygon', coordinates: [[[103, 1.3], [104, 1.3], [104, 1.4], [103, 1.4], [103, 1.3]]] })
const args = { filters: [filter.geoWithinGeoJSONRegion('lg', region, LIST, new Context().addMapKey('nested'))] }
verifyQueryResults(args, 'nested point list match', done)
})
})

@@ -788,7 +822,9 @@

})
it('should match locations in a map within a GeoJSON region in a nested context', function (done) {
const region = new GeoJSON({ type: 'Polygon', coordinates: [[[103, 1.3], [104, 1.3], [104, 1.4], [103, 1.4], [103, 1.3]]] })
const args = { filters: [filter.geoWithinGeoJSONRegion('mg', region, MAPVALUES, new Context().addMapKey('nested'))] }
verifyQueryResults(args, 'nested point map match', done)
describe('index with cdt context', function () {
helper.skipUnlessVersion('>= 6.1.0', this)
it('should match locations in a map within a GeoJSON region in a nested context', function (done) {
const region = new GeoJSON({ type: 'Polygon', coordinates: [[[103, 1.3], [104, 1.3], [104, 1.4], [103, 1.4], [103, 1.3]]] })
const args = { filters: [filter.geoWithinGeoJSONRegion('mg', region, MAPVALUES, new Context().addMapKey('nested'))] }
verifyQueryResults(args, 'nested point map match', done)
})
})

@@ -814,5 +850,8 @@

it('should match locations in a list within a radius from another location in a nested context', function (done) {
const args = { filters: [filter.geoWithinRadius('lg', 103.9135, 1.3085, 15000, LIST, new Context().addMapKey('nested'))] }
verifyQueryResults(args, 'nested point list match', done)
describe('index with cdt context', function () {
helper.skipUnlessVersion('>= 6.1.0', this)
it('should match locations in a list within a radius from another location in a nested context', function (done) {
const args = { filters: [filter.geoWithinRadius('lg', 103.9135, 1.3085, 15000, LIST, new Context().addMapKey('nested'))] }
verifyQueryResults(args, 'nested point list match', done)
})
})

@@ -825,5 +864,8 @@

it('should match locations in a map within a radius from another location in a nested context', function (done) {
const args = { filters: [filter.geoWithinRadius('mg', 103.9135, 1.3085, 15000, MAPVALUES, new Context().addMapKey('nested'))] }
verifyQueryResults(args, 'nested point map match', done)
describe('index with cdt context', function () {
helper.skipUnlessVersion('>= 6.1.0', this)
it('should match locations in a map within a radius from another location in a nested context', function (done) {
const args = { filters: [filter.geoWithinRadius('mg', 103.9135, 1.3085, 15000, MAPVALUES, new Context().addMapKey('nested'))] }
verifyQueryResults(args, 'nested point map match', done)
})
})

@@ -845,6 +887,9 @@ })

it('should match regions in a list that contain a GeoJSON point in a nested context', function (done) {
const point = new GeoJSON({ type: 'Point', coordinates: [103.913, 1.308] })
const args = { filters: [filter.geoContainsGeoJSONPoint('lg', point, LIST, new Context().addMapKey('nested'))] }
verifyQueryResults(args, 'nested region list match', done)
describe('index with cdt context', function () {
helper.skipUnlessVersion('>= 6.1.0', this)
it('should match regions in a list that contain a GeoJSON point in a nested context', function (done) {
const point = new GeoJSON({ type: 'Point', coordinates: [103.913, 1.308] })
const args = { filters: [filter.geoContainsGeoJSONPoint('lg', point, LIST, new Context().addMapKey('nested'))] }
verifyQueryResults(args, 'nested region list match', done)
})
})

@@ -858,6 +903,9 @@

it('should match regions in a map that contain a GeoJSON point in a nested context', function (done) {
const point = new GeoJSON({ type: 'Point', coordinates: [103.913, 1.308] })
const args = { filters: [filter.geoContainsGeoJSONPoint('mg', point, MAPVALUES, new Context().addMapKey('nested'))] }
verifyQueryResults(args, 'nested region map match', done)
describe('index with cdt context', function () {
helper.skipUnlessVersion('>= 6.1.0', this)
it('should match regions in a map that contain a GeoJSON point in a nested context', function (done) {
const point = new GeoJSON({ type: 'Point', coordinates: [103.913, 1.308] })
const args = { filters: [filter.geoContainsGeoJSONPoint('mg', point, MAPVALUES, new Context().addMapKey('nested'))] }
verifyQueryResults(args, 'nested region map match', done)
})
})

@@ -883,5 +931,8 @@

it('should match regions in a list that contain a lng/lat coordinate pair in a nested context', function (done) {
const args = { filters: [filter.geoContainsPoint('lg', 103.913, 1.308, LIST, new Context().addMapKey('nested'))] }
verifyQueryResults(args, 'nested region list match', done)
describe('index with cdt context', function () {
helper.skipUnlessVersion('>= 6.1.0', this)
it('should match regions in a list that contain a lng/lat coordinate pair in a nested context', function (done) {
const args = { filters: [filter.geoContainsPoint('lg', 103.913, 1.308, LIST, new Context().addMapKey('nested'))] }
verifyQueryResults(args, 'nested region list match', done)
})
})

@@ -894,5 +945,8 @@

it('should match regions in a map that contain a lng/lat coordinate pair in a nested context', function (done) {
const args = { filters: [filter.geoContainsPoint('mg', 103.913, 1.308, MAPVALUES, new Context().addMapKey('nested'))] }
verifyQueryResults(args, 'nested region map match', done)
describe('index with cdt context', function () {
helper.skipUnlessVersion('>= 6.1.0', this)
it('should match regions in a map that contain a lng/lat coordinate pair in a nested context', function (done) {
const args = { filters: [filter.geoContainsPoint('mg', 103.913, 1.308, MAPVALUES, new Context().addMapKey('nested'))] }
verifyQueryResults(args, 'nested region map match', done)
})
})

@@ -946,24 +1000,29 @@ })

})
it('should apply a user defined function and aggregate the results from a map', function (done) {
const args = {
filters: [filter.contains('nested', 'value', MAPKEYS)]
}
const query = client.query(helper.namespace, testSet, args)
query.apply('udf', 'count', function (error, result) {
if (error) throw error
expect(result).to.equal(3)
done()
describe('index with cdt context', function () {
helper.skipUnlessVersion('>= 6.1.0', this)
it('should apply a user defined function and aggregate the results from a map', function (done) {
const args = {
filters: [filter.contains('nested', 'value', MAPKEYS)]
}
const query = client.query(helper.namespace, testSet, args)
query.apply('udf', 'count', function (error, result) {
if (error) throw error
expect(result).to.equal(3)
done()
})
})
})
it('should apply a user defined function and aggregate the results from a nested map', function (done) {
const args = {
filters: [filter.contains('nested', 'value', MAPKEYS, new Context().addMapKey('doubleNested'))]
}
const query = client.query(helper.namespace, testSet, args)
query.apply('udf', 'count', function (error, result) {
if (error) throw error
expect(result).to.equal(3)
done()
describe('index with cdt context', function () {
helper.skipUnlessVersion('>= 6.1.0', this)
it('should apply a user defined function and aggregate the results from a nested map', function (done) {
const args = {
filters: [filter.contains('nested', 'value', MAPKEYS, new Context().addMapKey('doubleNested'))]
}
const query = client.query(helper.namespace, testSet, args)
query.apply('udf', 'count', function (error, result) {
if (error) throw error
expect(result).to.equal(3)
done()
})
})

@@ -1019,11 +1078,14 @@ })

})
it('returns a Promise that resolves to a Job with a filter containing a CDT context', function () {
const args = {
filters: [filter.contains('nested', 'value', MAPKEYS, new Context().addMapKey('doubleNested'))]
}
const query = client.query(helper.namespace, testSet, args)
return query.background('udf', 'noop')
.then(job => {
expect(job).to.be.instanceof(Job)
})
describe('index with cdt context', function () {
helper.skipUnlessVersion('>= 6.1.0', this)
it('returns a Promise that resolves to a Job with a filter containing a CDT context', function () {
const args = {
filters: [filter.contains('nested', 'value', MAPKEYS, new Context().addMapKey('doubleNested'))]
}
const query = client.query(helper.namespace, testSet, args)
return query.background('udf', 'noop')
.then(job => {
expect(job).to.be.instanceof(Job)
})
})
})

@@ -1030,0 +1092,0 @@ })

@@ -38,3 +38,3 @@ // *****************************************************************************

.then(() => client.exists(key))
.then(result => expect(result).to.be.false())
.then(result => expect(result).to.be.false)
})

@@ -63,3 +63,3 @@

.then(() => client.exists(key))
.then(result => expect(result).to.be.false())
.then(result => expect(result).to.be.false)
})

@@ -81,5 +81,5 @@

.then(() => client.exists(key))
.then(result => expect(result).to.be.false())
.then(result => expect(result).to.be.false)
})
})
})

@@ -20,2 +20,3 @@ // *****************************************************************************

/* global expect, describe, it, before, after, context */
/* eslint-disable no-unused-expressions */

@@ -74,5 +75,5 @@ const Aerospike = require('../lib/aerospike')

expect(scan.set).to.equal('demo')
expect(scan.concurrent).to.be.true()
expect(scan.concurrent).to.be.true
expect(scan.selected).to.eql(['a', 'b', 'c'])
expect(scan.nobins).to.be.false()
expect(scan.nobins).to.be.false
})

@@ -85,3 +86,3 @@

expect(scan.ns).to.equal(helper.namespace)
expect(scan.set).to.be.null()
expect(scan.set).to.be.null
expect(scan.selected).to.eql(['i'])

@@ -238,3 +239,3 @@ })

expect(record.key).to.be.instanceof(Key)
expect(record.key.key).to.not.be.empty()
expect(record.key.key).to.not.be.empty
stream.abort()

@@ -256,3 +257,3 @@ })

() => {
expect(dataHandlerCalled).to.be.true()
expect(dataHandlerCalled).to.be.true
done()

@@ -291,5 +292,5 @@ })

stream.on('data', record => {
expect(record.bins).to.be.empty()
expect(record.gen).to.be.ok()
expect(record.ttl).to.be.ok()
expect(record.bins).to.be.empty
expect(record.gen).to.be.ok
expect(record.ttl).to.be.ok
stream.abort()

@@ -296,0 +297,0 @@ })

@@ -21,2 +21,3 @@ // *****************************************************************************

/* global expect */
/* eslint-disable no-unused-expressions */

@@ -36,3 +37,3 @@ const helper = require('./test_helper')

const stats = client.stats()
expect(stats.commands).to.not.be.empty()
expect(stats.commands).to.not.be.empty
expect(stats.commands.inFlight).to.be.at.least(0)

@@ -44,3 +45,3 @@ expect(stats.commands.queued).to.be.at.least(0)

const stats = client.stats()
expect(stats.nodes).to.be.an('array').that.is.not.empty()
expect(stats.nodes).to.be.an('array').that.is.not.empty

@@ -47,0 +48,0 @@ const node = stats.nodes.pop()

@@ -27,5 +27,3 @@ // *****************************************************************************

const chai = require('chai')
const dirtyChai = require('dirty-chai')
const expect = chai.expect
chai.use(dirtyChai)
global.expect = expect

@@ -32,0 +30,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc