aerospike
Advanced tools
Comparing version 2.0.3 to 2.0.4
@@ -59,2 +59,2 @@ # Aerospike Node.js Client API | ||
database, including an architecture overview and in-depth feature guides, | ||
please visit http://www.aerospike.com/docs. | ||
please visit <a href="http://www.aerospike.com/docs">http://www.aerospike.com/docs</a>. |
@@ -0,1 +1,10 @@ | ||
v2.0.4 / 2016-05-09 | ||
=================== | ||
* **Fixes** | ||
* Query and Scan operations do not return record keys. | ||
[#126](https://github.com/aerospike/aerospike-client-nodejs/issues/126), | ||
[PR #127](https://github.com/aerospike/aerospike-client-nodejs/pull/127). | ||
Thanks to [@sel-fish](https://github.com/sel-fish)! | ||
v2.0.3 / 2016-05-03 | ||
@@ -2,0 +11,0 @@ =================== |
@@ -9,5 +9,3 @@ { | ||
"monospaceLinks": false, | ||
"default": { | ||
"outputSourceFiles": true | ||
}, | ||
"outputSourceFiles": true, | ||
"systemName": "Aerospike", | ||
@@ -20,3 +18,7 @@ "footer": "<div style=\"text-align: center\">High performance NoSQL database delivering speed at scale - <a href=\"http://www.aerospike.com/\">Aerospike.com</a></div>", | ||
"collapseSymbols": false, | ||
"inverseNav": true | ||
"inverseNav": true, | ||
"analytics": { | ||
"ua": "UA-50452230-2", | ||
"domain": "aerospike.com" | ||
} | ||
}, | ||
@@ -23,0 +25,0 @@ "opts": { |
@@ -17,3 +17,3 @@ /** | ||
* @param {string} set - The Set to which the key belongs. | ||
* @param {(string|number|Buffer)} value - The unique key value. Keys can be | ||
* @param {(string|number|Buffer)} key - The unique key value. Keys can be | ||
* strings, integers or an instance of the Buffer class. | ||
@@ -23,7 +23,10 @@ * | ||
* | ||
* const Aerospike = require('aerospike') | ||
* const Key = Aerospike.Key | ||
* | ||
* var key = new Key('test', 'demo', 123) | ||
* var key1 = new Key('test', 'demo', 12345) | ||
* var key2 = new Key('test', 'demo', 'abcde') | ||
* var key3 = new Key('test', 'demo', Buffer.from([0x62,0x75,0x66,0x66,0x65,0x72])) | ||
*/ | ||
function Key (ns, set, key) { | ||
function Key (ns, set, key, digest) { | ||
/** @member {string} Key#ns */ | ||
@@ -44,5 +47,5 @@ this.ns = ns | ||
*/ | ||
this.digest = null | ||
this.digest = digest || null | ||
} | ||
module.exports = Key |
@@ -18,4 +18,5 @@ // ***************************************************************************** | ||
const as = require('../build/Release/aerospike.node') | ||
const Job = require('./job') | ||
const Key = require('./key') | ||
const RecordStream = require('./record_stream') | ||
const Job = require('./job') | ||
@@ -261,3 +262,3 @@ const assert = require('assert') | ||
if (endCb) stream.on('end', endCb) | ||
this.client.as_client.queryAsync(this.ns, this.set, this, policy, function (error, record, meta) { | ||
this.client.as_client.queryAsync(this.ns, this.set, this, policy, function (error, record, meta, key) { | ||
if (error && error.code !== as.status.AEROSPIKE_OK) { | ||
@@ -268,3 +269,4 @@ stream.emit('error', error) | ||
} else { | ||
stream.emit('data', record, meta) | ||
key = new Key(key.ns, key.set, key.key, key.digest) | ||
stream.emit('data', record, meta, key) | ||
} | ||
@@ -271,0 +273,0 @@ return !stream.aborted |
@@ -98,2 +98,6 @@ // ***************************************************************************** | ||
* @param {?object} meta - Record meta data, e.g. ttl, generation, etc. | ||
* @param {?Key} key - The record's key. By default the server only stores the | ||
* key digest unless <code>Aerospike.policy.key.SEND</code> is used; so the | ||
* <code>key</code> property of the returned Key object might be | ||
* undefined and only <code>digest</code> will be populated. | ||
*/ | ||
@@ -100,0 +104,0 @@ |
@@ -19,2 +19,3 @@ // ***************************************************************************** | ||
const Job = require('./job') | ||
const Key = require('./key') | ||
const RecordStream = require('./record_stream') | ||
@@ -244,3 +245,3 @@ | ||
var scanID = Job.safeRandomJobID() | ||
this.client.as_client.scanAsync(this.ns, this.set, this, policy, scanID, function (error, record, meta) { | ||
this.client.as_client.scanAsync(this.ns, this.set, this, policy, scanID, function (error, record, meta, key) { | ||
if (error && error.code !== as.status.AEROSPIKE_OK) { | ||
@@ -251,3 +252,4 @@ stream.emit('error', error) | ||
} else { | ||
stream.emit('data', record, meta) | ||
key = new Key(key.ns, key.set, key.key, key.digest) | ||
stream.emit('data', record, meta, key) | ||
} | ||
@@ -254,0 +256,0 @@ return !stream.aborted |
{ | ||
"name": "aerospike", | ||
"version": "2.0.3", | ||
"version": "2.0.4", | ||
"description": "Aerospike Client Library", | ||
@@ -5,0 +5,0 @@ "tags": [ |
@@ -54,4 +54,8 @@ // ***************************************************************************** | ||
function put (n, keygen, recgen, metagen, callback) { | ||
var policy = { exists: Aerospike.policy.exists.CREATE_OR_REPLACE, timeout: 1000 } | ||
function put (n, keygen, recgen, metagen, policy, callback) { | ||
if (typeof policy === 'function') { | ||
callback = policy | ||
policy = null | ||
} | ||
policy = policy || { exists: Aerospike.policy.exists.CREATE_OR_REPLACE, timeout: 1000 } | ||
var generator = { | ||
@@ -58,0 +62,0 @@ key: keygen, |
@@ -26,2 +26,3 @@ // ***************************************************************************** | ||
const GeoJSON = Aerospike.GeoJSON | ||
const Key = Aerospike.Key | ||
@@ -180,2 +181,23 @@ const NUMERIC = Aerospike.indexDataType.NUMERIC | ||
describe('query.foreach()', function () { | ||
it('returns the key if it was stored on the server', function (done) { | ||
var unique_key = 'test/query/record_with_stored_key' | ||
var key = new Aerospike.Key(helper.namespace, testSet, unique_key) | ||
var record = { name: unique_key } | ||
var meta = { ttl: 300 } | ||
var policy = { key: Aerospike.policy.key.SEND } | ||
client.put(key, record, meta, policy, function (err) { | ||
if (err) throw err | ||
var query = client.query(helper.namespace, testSet) | ||
query.where(Aerospike.filter.equal('name', unique_key)) | ||
var stream = query.foreach() | ||
var count = 0 | ||
stream.on('data', function (_bins, _meta, key) { | ||
expect(++count).to.equal(1) | ||
expect(key).to.be.a(Key) | ||
expect(key.key).to.equal(unique_key) | ||
}) | ||
stream.on('end', done) | ||
}) | ||
}) | ||
it('should raise client errors asynchronously', function (done) { | ||
@@ -191,132 +213,132 @@ var query = client.query('test') | ||
}) | ||
}) | ||
context('filter predicates', function () { | ||
describe('filter.equal()', function () { | ||
it('should match equal integer values', function (done) { | ||
var args = { filters: [filter.equal('i', 5)] } | ||
verifyQueryResults(args, 'int match', done) | ||
}) | ||
context('filter predicates', function () { | ||
describe('filter.equal()', function () { | ||
it('should match equal integer values', function (done) { | ||
var args = { filters: [filter.equal('i', 5)] } | ||
verifyQueryResults(args, 'int match', done) | ||
}) | ||
it('should match equal string values', function (done) { | ||
var args = { filters: [filter.equal('s', 'banana')] } | ||
verifyQueryResults(args, 'string match', done) | ||
it('should match equal string values', function (done) { | ||
var args = { filters: [filter.equal('s', 'banana')] } | ||
verifyQueryResults(args, 'string match', done) | ||
}) | ||
}) | ||
}) | ||
describe('filter.range()', function () { | ||
it('should match integers within a range', function (done) { | ||
var args = { filters: [filter.range('i', 3, 7)] } | ||
verifyQueryResults(args, 'int match', done) | ||
}) | ||
describe('filter.range()', function () { | ||
it('should match integers within a range', function (done) { | ||
var args = { filters: [filter.range('i', 3, 7)] } | ||
verifyQueryResults(args, 'int match', done) | ||
}) | ||
it('should match integers in a list within a range', function (done) { | ||
var args = { filters: [filter.range('li', 3, 7, LIST)] } | ||
verifyQueryResults(args, 'int list match', done) | ||
}) | ||
it('should match integers in a list within a range', function (done) { | ||
var args = { filters: [filter.range('li', 3, 7, LIST)] } | ||
verifyQueryResults(args, 'int list match', done) | ||
}) | ||
it('should match integers in a map within a range', function (done) { | ||
var args = { filters: [filter.range('mi', 3, 7, MAPVALUES)] } | ||
verifyQueryResults(args, 'int map match', done) | ||
it('should match integers in a map within a range', function (done) { | ||
var args = { filters: [filter.range('mi', 3, 7, MAPVALUES)] } | ||
verifyQueryResults(args, 'int map match', done) | ||
}) | ||
}) | ||
}) | ||
describe('filter.contains()', function () { | ||
it('should match lists containing an integer', function (done) { | ||
var args = { filters: [filter.contains('li', 5, LIST)] } | ||
verifyQueryResults(args, 'int list match', done) | ||
}) | ||
describe('filter.contains()', function () { | ||
it('should match lists containing an integer', function (done) { | ||
var args = { filters: [filter.contains('li', 5, LIST)] } | ||
verifyQueryResults(args, 'int list match', done) | ||
}) | ||
it('should match maps containing an integer value', function (done) { | ||
var args = { filters: [filter.contains('mi', 5, MAPVALUES)] } | ||
verifyQueryResults(args, 'int map match', done) | ||
}) | ||
it('should match maps containing an integer value', function (done) { | ||
var args = { filters: [filter.contains('mi', 5, MAPVALUES)] } | ||
verifyQueryResults(args, 'int map match', done) | ||
}) | ||
it('should match lists containing a string', function (done) { | ||
var args = { filters: [filter.contains('ls', 'banana', LIST)] } | ||
verifyQueryResults(args, 'string list match', done) | ||
}) | ||
it('should match lists containing a string', function (done) { | ||
var args = { filters: [filter.contains('ls', 'banana', LIST)] } | ||
verifyQueryResults(args, 'string list match', done) | ||
}) | ||
it('should match maps containing a string value', function (done) { | ||
var args = { filters: [filter.contains('ms', 'banana', MAPVALUES)] } | ||
verifyQueryResults(args, 'string map match', done) | ||
}) | ||
it('should match maps containing a string value', function (done) { | ||
var args = { filters: [filter.contains('ms', 'banana', MAPVALUES)] } | ||
verifyQueryResults(args, 'string map match', done) | ||
}) | ||
it('should match maps containing a string key', function (done) { | ||
var args = { filters: [filter.contains('mks', 'banana', MAPKEYS)] } | ||
verifyQueryResults(args, 'string mapkeys match', done) | ||
it('should match maps containing a string key', function (done) { | ||
var args = { filters: [filter.contains('mks', 'banana', MAPKEYS)] } | ||
verifyQueryResults(args, 'string mapkeys match', done) | ||
}) | ||
}) | ||
}) | ||
describe('filter.geoWithinGeoJSONRegion()', function () { | ||
it('should match locations within a GeoJSON region', function (done) { | ||
var region = new GeoJSON({type: 'Polygon', coordinates: [[[103, 1.3], [104, 1.3], [104, 1.4], [103, 1.4], [103, 1.3]]]}) | ||
var args = { filters: [filter.geoWithinGeoJSONRegion('g', region)] } | ||
verifyQueryResults(args, 'point match', done) | ||
}) | ||
describe('filter.geoWithinGeoJSONRegion()', function () { | ||
it('should match locations within a GeoJSON region', function (done) { | ||
var region = new GeoJSON({type: 'Polygon', coordinates: [[[103, 1.3], [104, 1.3], [104, 1.4], [103, 1.4], [103, 1.3]]]}) | ||
var args = { filters: [filter.geoWithinGeoJSONRegion('g', region)] } | ||
verifyQueryResults(args, 'point match', done) | ||
}) | ||
it('should match locations in a list within a GeoJSON region', function (done) { | ||
var region = new GeoJSON({type: 'Polygon', coordinates: [[[103, 1.3], [104, 1.3], [104, 1.4], [103, 1.4], [103, 1.3]]]}) | ||
var args = { filters: [filter.geoWithinGeoJSONRegion('lg', region, LIST)] } | ||
verifyQueryResults(args, 'point list match', done) | ||
}) | ||
it('should match locations in a list within a GeoJSON region', function (done) { | ||
var region = new GeoJSON({type: 'Polygon', coordinates: [[[103, 1.3], [104, 1.3], [104, 1.4], [103, 1.4], [103, 1.3]]]}) | ||
var args = { filters: [filter.geoWithinGeoJSONRegion('lg', region, LIST)] } | ||
verifyQueryResults(args, 'point list match', done) | ||
}) | ||
it('should match locations in a map within a GeoJSON region', function (done) { | ||
var region = new GeoJSON({type: 'Polygon', coordinates: [[[103, 1.3], [104, 1.3], [104, 1.4], [103, 1.4], [103, 1.3]]]}) | ||
var args = { filters: [filter.geoWithinGeoJSONRegion('mg', region, MAPVALUES)] } | ||
verifyQueryResults(args, 'point map match', done) | ||
it('should match locations in a map within a GeoJSON region', function (done) { | ||
var region = new GeoJSON({type: 'Polygon', coordinates: [[[103, 1.3], [104, 1.3], [104, 1.4], [103, 1.4], [103, 1.3]]]}) | ||
var args = { filters: [filter.geoWithinGeoJSONRegion('mg', region, MAPVALUES)] } | ||
verifyQueryResults(args, 'point map match', done) | ||
}) | ||
}) | ||
}) | ||
describe('filter.geoWithinRadius()', function () { | ||
it('should match locations within a radius from another location', function (done) { | ||
var args = { filters: [filter.geoWithinRadius('g', 103.9135, 1.3085, 15000)] } | ||
verifyQueryResults(args, 'point match', done) | ||
}) | ||
describe('filter.geoWithinRadius()', function () { | ||
it('should match locations within a radius from another location', function (done) { | ||
var args = { filters: [filter.geoWithinRadius('g', 103.9135, 1.3085, 15000)] } | ||
verifyQueryResults(args, 'point match', done) | ||
}) | ||
it('should match locations in a list within a radius from another location', function (done) { | ||
var args = { filters: [filter.geoWithinRadius('lg', 103.9135, 1.3085, 15000, LIST)] } | ||
verifyQueryResults(args, 'point list match', done) | ||
}) | ||
it('should match locations in a list within a radius from another location', function (done) { | ||
var args = { filters: [filter.geoWithinRadius('lg', 103.9135, 1.3085, 15000, LIST)] } | ||
verifyQueryResults(args, 'point list match', done) | ||
}) | ||
it('should match locations in a map within a radius from another location', function (done) { | ||
var args = { filters: [filter.geoWithinRadius('mg', 103.9135, 1.3085, 15000, MAPVALUES)] } | ||
verifyQueryResults(args, 'point map match', done) | ||
it('should match locations in a map within a radius from another location', function (done) { | ||
var args = { filters: [filter.geoWithinRadius('mg', 103.9135, 1.3085, 15000, MAPVALUES)] } | ||
verifyQueryResults(args, 'point map match', done) | ||
}) | ||
}) | ||
}) | ||
describe('filter.geoContainsGeoJSONPoint()', function () { | ||
it('should match regions that contain a GeoJSON point', function (done) { | ||
var point = new GeoJSON({type: 'Point', coordinates: [103.913, 1.308]}) | ||
var args = { filters: [filter.geoContainsGeoJSONPoint('g', point)] } | ||
verifyQueryResults(args, 'region match', done) | ||
}) | ||
describe('filter.geoContainsGeoJSONPoint()', function () { | ||
it('should match regions that contain a GeoJSON point', function (done) { | ||
var point = new GeoJSON({type: 'Point', coordinates: [103.913, 1.308]}) | ||
var args = { filters: [filter.geoContainsGeoJSONPoint('g', point)] } | ||
verifyQueryResults(args, 'region match', done) | ||
}) | ||
it('should match regions in a list that contain a GeoJSON point', function (done) { | ||
var point = new GeoJSON({type: 'Point', coordinates: [103.913, 1.308]}) | ||
var args = { filters: [filter.geoContainsGeoJSONPoint('lg', point, LIST)] } | ||
verifyQueryResults(args, 'region list match', done) | ||
}) | ||
it('should match regions in a list that contain a GeoJSON point', function (done) { | ||
var point = new GeoJSON({type: 'Point', coordinates: [103.913, 1.308]}) | ||
var args = { filters: [filter.geoContainsGeoJSONPoint('lg', point, LIST)] } | ||
verifyQueryResults(args, 'region list match', done) | ||
}) | ||
it('should match regions in a map that contain a GeoJSON point', function (done) { | ||
var point = new GeoJSON({type: 'Point', coordinates: [103.913, 1.308]}) | ||
var args = { filters: [filter.geoContainsGeoJSONPoint('mg', point, MAPVALUES)] } | ||
verifyQueryResults(args, 'region map match', done) | ||
it('should match regions in a map that contain a GeoJSON point', function (done) { | ||
var point = new GeoJSON({type: 'Point', coordinates: [103.913, 1.308]}) | ||
var args = { filters: [filter.geoContainsGeoJSONPoint('mg', point, MAPVALUES)] } | ||
verifyQueryResults(args, 'region map match', done) | ||
}) | ||
}) | ||
}) | ||
describe('filter.geoContainsPoint()', function () { | ||
it('should match regions that contain a lng/lat coordinate pair', function (done) { | ||
var args = { filters: [filter.geoContainsPoint('g', 103.913, 1.308)] } | ||
verifyQueryResults(args, 'region match', done) | ||
}) | ||
describe('filter.geoContainsPoint()', function () { | ||
it('should match regions that contain a lng/lat coordinate pair', function (done) { | ||
var args = { filters: [filter.geoContainsPoint('g', 103.913, 1.308)] } | ||
verifyQueryResults(args, 'region match', done) | ||
}) | ||
it('should match regions in a list that contain a lng/lat coordinate pair', function (done) { | ||
var args = { filters: [filter.geoContainsPoint('lg', 103.913, 1.308, LIST)] } | ||
verifyQueryResults(args, 'region list match', done) | ||
}) | ||
it('should match regions in a list that contain a lng/lat coordinate pair', function (done) { | ||
var args = { filters: [filter.geoContainsPoint('lg', 103.913, 1.308, LIST)] } | ||
verifyQueryResults(args, 'region list match', done) | ||
}) | ||
it('should match regions in a map that contain a lng/lat coordinate pair', function (done) { | ||
var args = { filters: [filter.geoContainsPoint('mg', 103.913, 1.308, MAPVALUES)] } | ||
verifyQueryResults(args, 'region map match', done) | ||
it('should match regions in a map that contain a lng/lat coordinate pair', function (done) { | ||
var args = { filters: [filter.geoContainsPoint('mg', 103.913, 1.308, MAPVALUES)] } | ||
verifyQueryResults(args, 'region map match', done) | ||
}) | ||
}) | ||
@@ -323,0 +345,0 @@ }) |
@@ -23,2 +23,4 @@ // ***************************************************************************** | ||
const Key = Aerospike.Key | ||
const keygen = helper.keygen | ||
@@ -40,3 +42,4 @@ const metagen = helper.metagen | ||
var mgen = metagen.constant({ ttl: 300 }) | ||
putgen.put(numberOfRecords, kgen, rgen, mgen, function (key) { | ||
var policy = { key: Aerospike.policy.key.SEND, exists: Aerospike.policy.exists.CREATE_OR_REPLACE, timeout: 1000 } | ||
putgen.put(numberOfRecords, kgen, rgen, mgen, policy, function (key) { | ||
if (!key) done() | ||
@@ -103,4 +106,3 @@ }) | ||
var stream = scan.foreach() | ||
stream.on('error', function (error) { throw error }) | ||
stream.on('data', function (record) { recordsReceived++ }) | ||
stream.on('data', function () { recordsReceived++ }) | ||
stream.on('end', function () { | ||
@@ -112,2 +114,14 @@ expect(recordsReceived).to.not.be.lessThan(numberOfRecords) | ||
it('returns the key if it is stored on the server', function (done) { | ||
// requires { key: Aerospike.policy.key.SEND } when creating the record | ||
var scan = client.scan(helper.namespace, testSet) | ||
var stream = scan.foreach() | ||
stream.on('data', function (record, meta, key) { | ||
expect(key).to.be.a(Key) | ||
expect(key.key).to.not.be.empty() | ||
stream.abort() | ||
}) | ||
stream.on('end', done) | ||
}) | ||
context('with nobins set to true', function () { | ||
@@ -114,0 +128,0 @@ it('should return only meta data', function (done) { |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1070737
16721