Class: Record

Record

A record with the Aerospike database consists of one or more record "bins" (name-value pairs) and meta-data, incl. time-to-live and generation; a record is uniquely identified by it's key within a given namespace.


new Record()

Source:
Examples

Writing a new record with 5 bins while setting a record TTL.

const Aerospike = require('aerospike')

let bins = {
  int: 123,
  double: 3.1415,
  string: 'xyz',
  bytes: Buffer.from('hello world!'),
  list: [1, 2, 3],
  map: {num: 123, str: 'abc', list: ['a', 'b', 'c']}
}
let meta = {
  ttl: 386400 // 1 day
}
let key = new Aerospike.Key('test', 'demo', 'myKey')

Aerospike.connect()
  .then(client => {
    return client.put(key, bins, meta)
      .then(() => client.close())
      .catch(error => {
        client.close()
        return Promise.reject(error)
      })
  })
  .catch(error => console.error('Error:', error))

Fetching a single database record by it's key.

const Aerospike = require('aerospike')

let key = new Aerospike.Key('test', 'demo', 'myKey')

Aerospike.connect()
  .then(client => {
    client.get(key)
      .then(record => {
        console.info('Key:', record.key)
        console.info('Bins:', record.bins)
        console.info('TTL:', record.ttl)
        console.info('Gen:', record.gen)
      })
      .then(() => client.close())
      .catch(error => {
        client.close()
        return Promise.reject(error)
      })
  })
  .catch(error => console.error('Error:', error))

Members


bins :Object

Map of bin name to bin value.

Type:
  • Object
Source:

gen :number

Record modification count.

Type:
  • number
Source:

key :Key

Unique record identifier.

Type:
Source:

ttl :number

The record's remaining time-to-live in seconds, before the record will expire and be removed by the server.

Type:
  • number
Source: