Socket
Socket
Sign inDemoInstall

aerospike

Package Overview
Dependencies
Maintainers
2
Versions
135
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

aerospike - npm Package Compare versions

Comparing version 1.0.38 to 1.0.39

aerospike-1.0.39.tgz

115

docs/client.md

@@ -19,2 +19,4 @@ # Client Class

- [Methods](#methods)
- [add()](#add)
- [append()](#append)
- [batchExists()](#batchExists)

@@ -34,2 +36,3 @@ - [batchGet()](#batchGet)

- [operate()](#operate)
- [prepend()](#prepend)
- [put()](#put)

@@ -49,2 +52,75 @@ - [query()](#query)

################################################################################
add()
################################################################################
-->
<a name="add"></a>
### add(key, bins, metadata=null, policy=null, callback)
Adds integer values to existing record bin values. This call only works for integers values.
Parameters:
- `key` – A [Key object](datamodel.md#key), used to locate the record in the cluster.
- `bins` – A [Record Object](datamodel.md#record), used to specify the bins to be added with integer values.
- `metadata` – (optional) A [Metadata object](datamodel.md#metadata).
- `policy` – (optional) A [Operate Policy object](policies.md#OperatePolicy) to use for this operation.
- `callback` – The function to call when the operation completes with the results of the operation.
The parameters for the `callback` argument:
- `error` – The [Error object](datamodel.md#error) representing the status of
the operation.
- `record` – The [Record object](datamodel.md#record), containing the fields of the record.
- `metadata` – The [Metadata object](datamodel.md#record) for the `record`. Only generation is returned.
- `key` – The [Key object](datamodel.md#key) for the `record`.
Example:
```js
var bins = { itemsShopped: 5}
client.add(key, bins, function(error, record, metadata, key) {
// do something
});
```
<!--
################################################################################
append()
################################################################################
-->
<a name="append"></a>
### append(key, bins, metadata=null, policy=null, callback)
Appends bin string values to existing record bin values. This call only works for string values.
Parameters:
- `key` – A [Key object](datamodel.md#key), used to locate the record in the cluster.
- `bins` – A [Record Object](datamodel.md#record), used to specify the bins to be added with integer values.
- `metadata` – (optional) A [Metadata object](datamodel.md#metadata).
- `policy` – (optional) A [Operate Policy object](policies.md#OperatePolicy) to use for this operation.
- `callback` – The function to call when the operation completes with the results of the operation.
The parameters for the `callback` argument:
- `error` – The [Error object](datamodel.md#error) representing the status of
the operation.
- `record` – The [Record object](datamodel.md#record), containing the fields of the record.
- `metadata` – The [Metadata object](datamodel.md#record) for the `record`.Only generation is returned.
- `key` – The [Key object](datamodel.md#key) for the `record`.
Example:
```js
var bins = {LastMovieSeen: "Imitation Game"}
client.append(key, bins, function(error, record, metadata, key) {
// do something
});
```
<!--
################################################################################
batchExists()

@@ -558,3 +634,3 @@ ################################################################################

### operate(key, operations, policy=null, callback)
### operate(key, operations, metadata=null, policy=null, callback)

@@ -567,2 +643,3 @@ Performs multiple operations on a single record.

- `operations` – An array of operations.For the list of supported operations please refer [operators](operators.md)
- `metadata` – (optional) A [Metadata object](datamodel.md#metadata).
- `policy` – (optional) A [Operate Policy object](policies.md#OperatePolicy) to use for this operation.

@@ -594,3 +671,39 @@ - `callback` – The function to call when the operation completes with the results of the operation.

```
<!--
################################################################################
prepend()
################################################################################
-->
<a name="prepend"></a>
### prepend(key, bins, metadata=null, policy=null, callback)
Prepends bin string values to existing record bin values. This call only works for string values.
Parameters:
- `key` – A [Key object](datamodel.md#key), used to locate the record in the cluster.
- `bins` – A [Record Object](datamodel.md#record), used to specify the bins to be added with integer values.
- `metadata` – (optional) A [Metadata object](datamodel.md#metadata).
- `policy` – (optional) A [Operate Policy object](policies.md#OperatePolicy) to use for this operation.
- `callback` – The function to call when the operation completes with the results of the operation.
The parameters for the `callback` argument:
- `error` – The [Error object](datamodel.md#error) representing the status of
the operation.
- `record` – The [Record object](datamodel.md#record), containing the fields of the record.
- `metadata` – The [Metadata object](datamodel.md#record) for the `record`. Only generation is returned.
- `key` – The [Key object](datamodel.md#key) for the `record`.
Example:
```js
var bins = {FirstMovieSeen: "12 Angry Man"}
client.prepend(key, bins, function(error, record, metadata, key) {
// do something
});
```
<!--

@@ -597,0 +710,0 @@ ################################################################################

2

docs/configuration.md

@@ -26,3 +26,3 @@ # Configuration

log : {
log : aerospike.log.INFO,
level: aerospike.log.INFO,
file : fd // fd opened by the application using fs.open()

@@ -29,0 +29,0 @@ },

@@ -30,2 +30,6 @@ # Query Class

Statement is used to specify the attributes of query object, during the object creation.
The statement should be well formed for creating a query object, in case of error during the
query creation, an exception is thrown with appropriate error messages.
###Statement Attributes

@@ -32,0 +36,0 @@

@@ -223,2 +223,71 @@ var as = require('../build/Release/aerospike.node')

}
parseOperateArgs = function(args)
{
var arglength = args.length;
var options = {}
options.callback = args[arglength-1];
if( arglength == 3)
{
options.policy = undefined;
options.metadata = undefined;
}
else if( arglength == 4)
{
options.metadata = args[arglength-2];
options.policy = undefined;
}
else if( arglength == 5)
{
options.policy = args[arglength-2];
options.metadata = args[arglength-3];
}
return options;
}
add = function(key, bins, metadata, policy, callback)
{
var options = parseOperateArgs(arguments);
// populate ops from bins argument here
var ops= new Array;
for( var prop in bins) {
ops.push(aerospike.operator.incr(prop, bins[prop]));
}
this.operate(key, ops, options.metadata, options.policy, options.callback);
}
append = function(key, bins, metadata, policy, callback)
{
var options = parseOperateArgs(arguments);
// populate ops from bins argument here
var ops= new Array;
for( var prop in bins) {
ops.push(aerospike.operator.append(prop, bins[prop]));
}
this.operate(key, ops, options.metadata, options.policy, options.callback);
}
prepend = function(key, bins, metadata, policy, callback)
{
var options = parseOperateArgs(arguments);
// populate ops from bins argument here
var ops= new Array;
for( var prop in bins) {
ops.push(aerospike.operator.prepend(prop, bins[prop]));
}
this.operate(key, ops, options.metadata, options.policy, options.callback);
}
/******************************************************************************

@@ -267,2 +336,15 @@ * `aerospike` shim

}
if( !proto.add) {
proto.add = add;
}
if( !proto.append) {
proto.append = append;
}
if( !proto.prepend) {
proto.prepend = prepend;
}
return client;

@@ -269,0 +351,0 @@ };

{
"name" : "aerospike",
"version" : "1.0.38",
"version" : "1.0.39",
"description" : "Aerospike Client Library",

@@ -5,0 +5,0 @@ "tags" : [ "aerospike", "database", "nosql" ],

@@ -150,3 +150,3 @@ /*******************************************************************************

// this high for low-end hosts
this.timeout(3000);
this.timeout(5000);

@@ -153,0 +153,0 @@ // number of records

@@ -226,3 +226,275 @@ /*******************************************************************************

});
it('should prepend using prepend API and verify the bin', function(done) {
// generators
var kgen = keygen.string(options.namespace, options.set, {prefix: "test/get/"});
var mgen = metagen.constant({ttl: 1000});
var rgen = recgen.constant({i: 123, s: "abc"});
// values
var key = kgen();
var meta = mgen(key);
var record = rgen(key, meta);
// write the record then check
client.put(key, record, meta, function(err, key) {
var bin = { s: 'def'}
client.prepend(key, bin, function(err, record1, metadata1, key1) {
expect(err).to.be.ok();
expect(err.code).to.equal(status.AEROSPIKE_OK);
client.get(key, function(err, record2, metadata2, key2) {
expect(err).to.be.ok();
expect(err.code).to.equal(status.AEROSPIKE_OK);
expect(record['i']).to.equal(record2['i']);
expect('def'+record['s'] ).to.equal(record2['s']);
client.remove(key2, function(err, key){
done();
});
});
});
});
});
it('should prepend using prepend API and verify the bin with metadata', function(done) {
// generators
var kgen = keygen.string(options.namespace, options.set, {prefix: "test/get/"});
var mgen = metagen.constant({ttl: 1000});
var rgen = recgen.constant({i: 123, s: "abc"});
// values
var key = kgen();
var meta = mgen(key);
var record = rgen(key, meta);
// write the record then check
client.put(key, record, meta, function(err, key) {
var bin = { s: 'def'}
client.prepend(key, bin, meta, function(err, record1, metadata1, key1) {
expect(err).to.be.ok();
expect(err.code).to.equal(status.AEROSPIKE_OK);
client.get(key, function(err, record2, metadata2, key2) {
expect(err).to.be.ok();
expect(err.code).to.equal(status.AEROSPIKE_OK);
expect(record['i']).to.equal(record2['i']);
expect('def'+record['s'] ).to.equal(record2['s']);
client.remove(key2, function(err, key){
done();
});
});
});
});
});
it('should append a bin using append API and verify the bin', function(done) {
// generators
var kgen = keygen.string(options.namespace, options.set, {prefix: "test/get/"});
var mgen = metagen.constant({ttl: 1000});
var rgen = recgen.constant({i: 123, s: "abc"});
// values
var key = kgen();
var meta = mgen(key);
var record = rgen(key, meta);
// write the record then check
client.put(key, record, meta, function(err, key) {
var bin = { s: 'def'};
client.append(key, bin, function(err, record1, metadata1, key1) {
expect(err).to.be.ok();
expect(err.code).to.equal(status.AEROSPIKE_OK);
client.get(key, function(err, record2, metadata2, key2) {
expect(err).to.be.ok();
expect(err.code).to.equal(status.AEROSPIKE_OK);
expect(record['i']).to.equal(record2['i']);
expect(record['s'] + 'def').to.equal(record2['s']);
client.remove(key2, function(err, key){
done();
});
});
});
});
});
it('should append a bin using append API and verify the bin with metadata', function(done) {
// generators
var kgen = keygen.string(options.namespace, options.set, {prefix: "test/get/"});
var mgen = metagen.constant({ttl: 1000});
var rgen = recgen.constant({i: 123, s: "abc"});
// values
var key = kgen();
var meta = mgen(key);
var record = rgen(key, meta);
// write the record then check
client.put(key, record, meta, function(err, key) {
var bin = { s: 'def'};
client.append(key, bin, meta, function(err, record1, metadata1, key1) {
expect(err).to.be.ok();
expect(err.code).to.equal(status.AEROSPIKE_OK);
client.get(key, function(err, record2, metadata2, key2) {
expect(err).to.be.ok();
expect(err.code).to.equal(status.AEROSPIKE_OK);
expect(record['i']).to.equal(record2['i']);
expect(record['s'] + 'def').to.equal(record2['s']);
client.remove(key2, function(err, key){
done();
});
});
});
});
});
it('should add a value to a bin and verify', function(done) {
// generators
var kgen = keygen.string(options.namespace, options.set, {prefix: "test/get/"});
var mgen = metagen.constant({ttl: 1000});
var rgen = recgen.constant({i: 123, s: "abc"});
// values
var key = kgen();
var meta = mgen(key);
var record = rgen(key, meta);
// write the record then check
client.put(key, record, meta, function(err, key) {
var bin = { i : 432}
client.add(key, bin, function(err, record1, metadata1, key1) {
expect(err).to.be.ok();
expect(err.code).to.equal(status.AEROSPIKE_OK);
client.get(key, function(err, record2, metadata2, key2) {
expect(err).to.be.ok();
expect(err.code).to.equal(status.AEROSPIKE_OK);
expect(record['i'] + 432).to.equal(record2['i']);
expect(record['s']).to.equal(record2['s']);
client.remove(key2, function(err, key){
done();
});
});
});
});
});
it('should add a value to a bin with metadata and verify', function(done) {
// generators
var kgen = keygen.string(options.namespace, options.set, {prefix: "test/get/"});
var mgen = metagen.constant({ttl: 1000});
var rgen = recgen.constant({i: 123, s: "abc"});
// values
var key = kgen();
var meta = mgen(key);
var record = rgen(key, meta);
// write the record then check
client.put(key, record, meta, function(err, key) {
var bin = { i : 432}
client.add(key, bin, meta, function(err, record1, metadata1, key1) {
expect(err).to.be.ok();
expect(err.code).to.equal(status.AEROSPIKE_OK);
client.get(key, function(err, record2, metadata2, key2) {
expect(err).to.be.ok();
expect(err.code).to.equal(status.AEROSPIKE_OK);
expect(record['i'] + 432).to.equal(record2['i']);
expect(record['s']).to.equal(record2['s']);
client.remove(key2, function(err, key){
done();
});
});
});
});
});
it('should add a string value to a bin and expected fail', function(done) {
// generators
var kgen = keygen.string(options.namespace, options.set, {prefix: "test/get/"});
var mgen = metagen.constant({ttl: 1000});
var rgen = recgen.constant({i: 123, s: "abc"});
// values
var key = kgen();
var meta = mgen(key);
var record = rgen(key, meta);
// write the record then check
client.put(key, record, meta, function(err, key) {
var bin = { i : "str"}
client.add(key, bin, meta, function(err, record1, metadata1, key1) {
expect(err).to.be.ok();
expect(err.code).to.equal(status.AEROSPIKE_ERR_REQUEST_INVALID);
done();
});
});
});
it('should append a bin of type integer using append API and expected to fail', function(done) {
// generators
var kgen = keygen.string(options.namespace, options.set, {prefix: "test/get/"});
var mgen = metagen.constant({ttl: 1000});
var rgen = recgen.constant({i: 123, s: "abc"});
// values
var key = kgen();
var meta = mgen(key);
var record = rgen(key, meta);
// write the record then check
client.put(key, record, meta, function(err, key) {
var bin = { s: 123};
client.append(key, bin, meta, function(err, record1, metadata1, key1) {
expect(err).to.be.ok();
expect(err.code).to.equal(status.AEROSPIKE_ERR_REQUEST_INVALID);
done();
});
});
});
it('should prepend an integer using prepend API and expect to fail', function(done) {
// generators
var kgen = keygen.string(options.namespace, options.set, {prefix: "test/get/"});
var mgen = metagen.constant({ttl: 1000});
var rgen = recgen.constant({i: 123, s: "abc"});
// values
var key = kgen();
var meta = mgen(key);
var record = rgen(key, meta);
// write the record then check
client.put(key, record, meta, function(err, key) {
var bin = { s: 123}
client.prepend(key, bin, meta, function(err, record1, metadata1, key1) {
expect(err).to.be.ok();
expect(err.code).to.equal(status.AEROSPIKE_ERR_REQUEST_INVALID);
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

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc