- Description:
This module provides functions to easily define operations to be performed on a record via the
Client#operate
command.
- Source:
- See:
This module provides functions to easily define operations to
be performed on a record via the Client#operate
command.
Example
const Aerospike = require('aerospike')
const op = Aerospike.operations
const key = new Aerospike.Key('test', 'demo', 'mykey1')
// INSERT HOSTNAME AND PORT NUMBER OF AEROSPIKE SERVER NODE HERE!
var config = {
hosts: '192.168.33.10:3000',
// Timeouts disabled, latency dependent on server location. Configure as needed.
policies: {
operate : new Aerospike.OperatePolicy({socketTimeout : 0, totalTimeout : 0}),
write : new Aerospike.WritePolicy({socketTimeout : 0, totalTimeout : 0}),
}
}
var ops = [
op.append('a', 'xyz'),
op.incr('b', 10),
op.read('b')
]
Aerospike.connect(config, (error, client) => {
if (error) throw error
client.put(key, { a: 'abc', b: 42 }, (error) => {
if (error) throw error
client.operate(key, ops, (error, record) => {
if (error) throw error
console.log(record.bins) // => { b: 52 }
client.close()
})
})
})
Classes
Methods
(static) add(bin, value) → {Operation}
Increment the value of the bin by the given value.
- Description:
The bin must contain either an Integer or a Double, and the value must be of the same type.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
bin |
string | The name of the bin. |
value |
number | Object | The |
Returns:
Operation that can be passed to the Client#operate
command.
- Type
- Operation
(static) append(bin, value) → {Operation}
Append the value to the bin.
- Description:
The bin must contain either String or a Byte Array, and the value must be of the same type.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
bin |
string | The name of the bin. |
value |
string | Buffer | The value to append to the bin. |
Returns:
Operation that can be passed to the Client#operate
command.
- Type
- Operation
(static) delete() → {Operation}
Deletes the record.
- Description:
Returns true on success. Otherwise an error occurred.
- Source:
- Since:
- v3.14.0
Returns:
Operation that can be passed to the Client#operate
command.
- Type
- Operation
(static) incr()
Alias for the module:aerospike/operations.add
operation.
- Source:
(static) prepend(bin, value) → {Operation}
Prepend the value to the bin.
- Description:
The bin must contain either String or a Byte Array, and the value must be of the same type.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
bin |
string | The name of the bin. |
value |
string | Buffer | The value to prepend to the bin. |
Returns:
Operation that can be passed to the Client#operate
command.
- Type
- Operation
(static) read(bin) → {Operation}
Read the value of the bin.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
bin |
string | The name of the bin. |
Returns:
Operation that can be passed to the Client#operate
command.
- Type
- Operation
(static) touch(ttlopt) → {Operation}
Update the TTL (time-to-live) for a record.
- Description:
If the optional
ttl
parameter is not specified, the server will reset the record's TTL value to the default TTL value for the namespace.
- Source:
- See:
-
module:aerospike.ttl
for "special" TTL values.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
ttl |
number |
<optional> |
Aerospike.ttl.NAMESPACE_DEFAULT
|
The new, relative TTL to set for the record, when it is touched. |
Returns:
Operation that can be passed to the Client#operate
command.
- Type
- Operation
(static) write(bin, value) → {Operation}
Update the value of the bin.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
bin |
string | The name of the bin. |
value |
any | The value to set the bin to. |
Returns:
Operation that can be passed to the Client#operate
command.
- Type
- Operation