Double

Double

All the decimal values with valid fractions (e.g. 123.45) will be stored as double data type in Aerospike. To store decimal values with 0 fraction as double, the value needs to be wrapped in a Double class instance

Constructor

new Double(value)

Creates a new Double instance.

Source:
Example
const Aerospike = require('aerospike')
const Double = Aerospike.Double

// 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: {
    read : new Aerospike.ReadPolicy({socketTimeout : 0, totalTimeout : 0}),
    write : new Aerospike.WritePolicy({socketTimeout : 0, totalTimeout : 0})
  }
}
// (1.0) must be wrapped with "Double" in order to be added to another double.
// (6.283) does not need to be wrapped, but it may be wrapped if convenient.
ops = [Aerospike.operations.incr('d', 6.283),
       Aerospike.operations.incr('d', new Double(1.0))]
const key = new Aerospike.Key('test', 'demo', 'myDouble')
var record = { d: 3.1415 }
Aerospike.connect(config, (error, client) => {
  if (error) throw error
  client.put(key, record, (error) => {
    if (error) throw error
    client.operate(key, ops, (error) => {
      if (error) throw error
      client.get(key, (error, record) => {
        console.log(record.bins.d) // => 10.4245
        client.close()
      })
    })
  })
})
Parameters:
Name Type Description
value number

The value of the double.

Methods

value() → {number}

Source:
Returns:

value of the Double

Type
number