aerospike

Description:
  • The Aerospike module is the main entry point for the Aerospike Node.js Client API. It provides methods for creating new client instances that connect to a specific Aerospike server cluster.

Source:

The Aerospike module is the main entry point for the Aerospike Node.js Client API. It provides methods for creating new client instances that connect to a specific Aerospike server cluster.

Members

(static) AerospikeError

AerospikeError class

Description:
  • In case of any errors during the database operation the client will return an AerospikeError instance (either through the provided callback or when the returned Promise gets resolved).

Source:

In case of any errors during the database operation the client will return an AerospikeError instance (either through the provided callback or when the returned Promise gets resolved).

(static) Bin

Bin class

Description:
  • In the Aerospike database, each record (similar to a row in a relational database) stores data using one or more bins (like columns in a relational database).

Source:

In the Aerospike database, each record (similar to a row in a relational database) stores data using one or more bins (like columns in a relational database).

(static) Client

Client class

Description:
  • The main interface of the Aerospike client. Commands such as put, get or query can be sent to an Aerospike database cluster using the Client class.

Source:

The main interface of the Aerospike client. Commands such as put, get or query can be sent to an Aerospike database cluster using the Client class.

(static) Config

Config class

Description:
  • The Config class contains the settings for an Aerospike client instance, including the list of seed hosts, default policies, and other settings.

Source:

The Config class contains the settings for an Aerospike client instance, including the list of seed hosts, default policies, and other settings.

(static) Double

Double class

Description:
  • 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.

Source:

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.

(static) GeoJSON

GeoJSON class

Description:
  • Representation of a GeoJSON value. Since GeoJSON values are JSON objects they need to be wrapped in the GeoJSON class so that the client can distinguish them from other types of objects.

Source:

Representation of a GeoJSON value. Since GeoJSON values are JSON objects they need to be wrapped in the GeoJSON class so that the client can distinguish them from other types of objects.

(static) Key

Key class

Description:
  • A key uniquely identifies a record in the Aerospike database within a given namespace.

Source:

A key uniquely identifies a record in the Aerospike database within a given namespace.

(static) Record

Record class

Description:
  • 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.

Source:

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.

(static) admin

aerospike/admin module

Description:
  • The admin module contains classes associated with RBAC (Role Based Access Control) security methods defined in Client

Source:

The admin module contains classes associated with RBAC (Role Based Access Control) security methods defined in Client

(static) auth :number

Enumeration of auth modes

Description:
  • Authentication mode when user/password is defined.

    Note: The Node.js client's TLS support is currently limited to Linux, and therefore secure, external authentication (e.g. LDAP) is only supported on Linux as well. External authentication can be used on macOS or Windows but it will not be secure!

Source:
Properties:
Name Type Description
INTERNAL number

Use internal authentication only. Hashed password is stored on the server. Do not send clear password. This is the default.

EXTERNAL number

Use external authentication (like LDAP). Specific external authentication is configured on server. If TLS is enabled, send clear password on node login via TLS. Throws exception, if TLS is not enabled.

EXTERNAL_INSECURE number

Use external authentication (like LDAP). Specific external authentication is configured on server. Send clear password on node login whether or not TLS is enabled. This mode should only be used for testing purposes because it is not secure authentication.

AUTH_PKI number

Use PKI authentication. Authentication and authorization is based on a certificate. No user name or password needs to be configured. Requires mTLS and a client certificate.

Authentication mode when user/password is defined.

Note: The Node.js client's TLS support is currently limited to Linux, and therefore secure, external authentication (e.g. LDAP) is only supported on Linux as well. External authentication can be used on macOS or Windows but it will not be secure!

Type:
  • number
Examples

Using external authentication mode, e.g. to use LDAP authentication

const Aerospike = require('aerospike')

const config = {
  user: process.env.ADMIN_USER,
  password: process.env.ADMIN_PASSWORD,
  authMode: Aerospike.auth.EXTERNAL
}

Using PKI authentication mode

const Aerospike = require('aerospike')

const config = {
  hosts: [
      { addr: 'bob-cluster-a', port: process.env.PORT}
  ],
  tls: {
     cafile: process.env.CAFILE,
     keyfile: process.env.KEYFILE,
     certfile: process.env.CERT,
  }
  authMode: Aerospike.auth.AUTH_PKI,
}


Aerospike.connect(config).then(async (client) => {
  const info = await client.infoAny().then(Aerospike.info.parse)
  console.info(info)
  client.close()
})

(static) batchType

aerospike/batch_type module

Description:
Source:

The aerospike/batch_type module contains a list of batch record types.

(static) bitwise

aerospike/bitwise module

Description:
  • The bitwise module defines operations on the bytes data type.

Source:

The bitwise module defines operations on the bytes data type.

(static) cdt

aerospike/cdt module

Description:
  • The cdt module provides the CdtContext class for operations on nested lists and maps.

Source:

The cdt module provides the CdtContext class for operations on nested lists and maps.

(static) features

aerospike/features module

Description:
  • The features module contains a list of the feature strings used by the Aerospike server.

Source:

The features module contains a list of the feature strings used by the Aerospike server.

(static) filter

aerospike/filter module

Description:
  • The filter module provides functions to create secondary index (SI) filter predicates for use in query operations via the Client#query command.

Source:

The filter module provides functions to create secondary index (SI) filter predicates for use in query operations via the Client#query command.

(static) hll

aerospike/hll module

Description:
  • The hll module defines operations on the HyperLogLog data type.

Source:
Since:
  • v3.16.0

The hll module defines operations on the HyperLogLog data type.

(static) indexDataType :number

Enumeration of SI data types.

Source:
See:
Properties:
Name Type Description
STRING number

Values contained in the SI are strings.

NUMERIC number

Values contained in the SI are integers.

GEO2DSPHERE number

Values contained in the SI are GeoJSON values (points or polygons).

Type:
  • number

(static) indexType :number

Enumeration of SI types.

Source:
See:
Properties:
Name Type Description
DEFAULT number

Default SI type for bins containing scalar values (i.e. integer, string).

LIST number

SI for bins containing ⇑Lists; The index will be built over the individual entries of the list.

MAPKEYS number

SI for bins containing ⇑Maps; The index will be built over the individual keys of the map entries.

MAPVALUES number

SI for bins containing ⇑Maps; The index will be built over the individual values of the map entries.

Type:
  • number

(static) info

aerospike/info module

Description:
  • The info protocol provides access to configuration and statistics for the Aerospike server. The info module provides utility functions for parsing the info data returned by the Aerospike server.

Source:

The info protocol provides access to configuration and statistics for the Aerospike server. The info module provides utility functions for parsing the info data returned by the Aerospike server.

(static) jobStatus :number

Enumeration of job status codes.

Source:
See:
  • Job#infoCallback returns the job status.
Properties:
Name Type Description
UNDEF number

The job status is undefined. This is likely due to the status not being properly checked.

INPROGRESS number

The job is currently running.

COMPLETED number

The job completed successfully.

Type:
  • number

(static) language :number

Enumeration of UDF types.

Source:
Properties:
Name Type Description
LUA number

Lua (only supported UDF type at the moment)

Type:
  • number

(static) lists

aerospike/lists module

Description:
  • The lists module defines operations on the Lists complex data type.

Source:

The lists module defines operations on the Lists complex data type.

(static) log :number

Enumeration of log levels

Source:
See:
Properties:
Name Type Description
OFF number

Turn off logging

ERROR number

Log messages at ERROR level

WARN number

Log messages at WARN level or below

INFO number

Log messages at INFO level or below

DEBUG number

Log messages at DEBUG level or below

TRACE number

Log messages at TRACE level or below

Type:
  • number
Example

Setting log level for new client

const Aerospike = require('aerospike')
// INSERT HOSTNAME AND PORT NUMBER OF AEROSPIKE SERVER NODE HERE!
var config = {
  hosts: '192.168.33.10:3000',
  log: { level: Aerospike.log.DEBUG },
  // 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})
  }
}
Aerospike.connect(config, (error, client) => {
  if (error) throw error
  var key = new Aerospike.Key('test', 'demo', 'k1')
  client.put(key, {example: 31}, (error) => {
    if (error) throw error
    client.get(key, (error, record) => {
      console.info(record)
      client.close()
    })
  })
})

(static, constant) maps

aerospike/maps module

Description:
  • The maps module defines operations on the Maps complex data type.

Source:

The maps module defines operations on the Maps complex data type.

(static) operations

aerospike/operations module

Description:
Source:

The operations module provides functions to create operations for the Client#operate command.

(static) policy

aerospike/policy module

Description:
  • The policy module defines policies and policy values that define the behavior of database operations.

Source:

The policy module defines policies and policy values that define the behavior of database operations.

(static) privilegeCode

aerospike/privilege_code module

Description:
  • The aerospike/privilege_code module is comprised of permission codes which define the type of permission granted for a user's role.

Source:

The aerospike/privilege_code module is comprised of permission codes which define the type of permission granted for a user's role.

(static) regex :number

POSIX regex compilation flags.

Source:
Properties:
Name Type Description
BASIC number

Use basic regular expression syntax.

EXTENDED number

Use extended regular expression syntax.

ICASE number

Ignore case when matching.

NEWLINE number

Anchors do not match at newline characters in the string.

Type:
  • number

(static) status

aerospike/status module

Description:
  • The status module contains a list of the status codes returned by the Aerospike server.

Source:

The status module contains a list of the status codes returned by the Aerospike server.

(static) ttl :number

Enumertion of special TTL (time-to-live) values.

Description:
  • Instead of specifying a TTL in seconds, you can set the TTL to one of these special values when creating or updating a record.

Source:
Properties:
Name Type Description
NAMESPACE_DEFAULT number

Use the default TTL value for the namespace of the record.

NEVER_EXIRE number

Never expire the record.

DONT_UPDATE number

Update the record without changing the record's TTL value. Requires server 3.10.1 or later.

Instead of specifying a TTL in seconds, you can set the TTL to one of these special values when creating or updating a record.

Type:
  • number
Example

Use ttl.DONT_UPDATE to change the value of a record bin without changing the records expiry time

const Aerospike = require('aerospike')
const Key = Aerospike.Key
// 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})
  }
}
Aerospike.connect(config, (error, client) => {
  if (error) throw error
  let key = new Key('test', 'demo', 'key1')
  let bins = { 'int': 1 }
  let meta = { ttl: 86400 }

  client.put(key, bins, meta, (error) => {
    if (error) throw error

    bins = { 'int': 2 }
    meta = { ttl: Aerospike.ttl.DONT_UPDATE }
    client.put(key, bins, meta, (error) => {
      if (error) throw error

      client.get(key, (error, record) => {
        if (error) throw error

        console.log(record.bins.int) // => 2
        console.log(record.ttl)      // => 86400
        client.close()
      })
    })
  })
})

(inner, constant) exp

aerospike/exp module

Description:
  • The exp module provides functions to create expressions for use in key operations via the Client#operate command.

Source:

The exp module provides functions to create expressions for use in key operations via the Client#operate command.

Methods

(static) client(configopt)

Description:
  • Creates a new Client instance.

Source:
Parameters:
Name Type Attributes Description
config Config <optional>

The configuration for the client.

(static) connect(configopt, callbackopt) → (nullable) {Promise}

Description:
  • Creates a new Client instance and connects to the Aerospike cluster.

Source:
Examples

Connection can be established using the aerospike module.

const Aerospike = require('aerospike')

// INSERT HOSTNAME AND PORT NUMBER OF AEROSPIKE SERVER NODE HERE!
var config = {
  hosts: '192.168.33.10:3000',
}

Aerospike.connect(config, (err, client) => {
  console.log("Connected. Closing now.")
  client.close()
})

Connection can also be established using the Client module.

const Aerospike = require('aerospike')

// INSERT HOSTNAME AND PORT NUMBER OF AEROSPIKE SERVER NODE HERE!
var config = {
  hosts: '192.168.33.10:3000',
}

const client = Aerospike.client(config)
client.connect((err) => {
  console.log("Connected. Closing now.")
  client.close()
})

A connection established using callback function.

const Aerospike = require('aerospike')

// INSERT HOSTNAME AND PORT NUMBER OF AEROSPIKE SERVER NODE HERE!
var config = {
  hosts: '192.168.33.10:3000',
}
Aerospike.connect(config, (error, client) => {
  if (error) {
    console.error('Failed to connect to cluster: %s', error.message)
    process.exit()
  } else {
    // client is ready to accept commands
    console.log("Connected. Now closing connection.")
    client.close()
  }
})

A connection established by returning a Promise.

const Aerospike = require('aerospike')
// INSERT HOSTNAME AND PORT NUMBER OF AEROSPIKE SERVER NODE HERE!
var config = {
  hosts: '192.168.33.10:3000',
}
Aerospike.connect(config)
  .then(client => {
    // client is ready to accept commands
    console.log("Connected. Now Closing Connection.")
    client.close()
  })
  .catch(error => {
    console.error('Failed to connect to cluster: %s', error.message)
  })
Parameters:
Name Type Attributes Description
config Config <optional>

The configuration for the client.

callback connectCallback <optional>

The function to call, once the client is connected to the cluster successfully.

Returns:

If no callback function is passed, the function returns a Promise resolving to the connected client.

Type
Promise

(static) releaseEventLoop()

Release event loop resources held by the module, which could keep the Node.js event loop from shutting down properly.

Description:
  • This method releases some event loop resources held by the Aerospike module and the Aerospike C client library, such as libuv handles and timers. If not released, these handles will prevent the Node.js event loop from shutting down, i.e. it will keep your application from terminating.

    The Aerospike module keeps an internal counter of active Client instances, i.e. instances which have not been close()'d yet. If a client is closed and the counter reaches zero, this method will be called automatically, unless Client#close is called with releaseEventLoop set to false. (The default is true.)

    If an application needs to create multiple client instance, i.e. to connect to multiple, different clusters, the event loop resources will be managed automatically, as long as at least once client instance is active at any given time, until the application terminates.

    If, however, there could be one or more intermittent time periods, during which no client is active (i.e. the internal client counter reaches zero), then the clients need to be closed with releaseEventLoop set to false and the event loop needs to be released explicitly by calling releaseEventLoop().

Source:

(static) setDefaultLogging(log)

Description:
  • Sets the global, default log level and destination. The default log settings are used for all new client instances, unless different log settings are supplied in the client's configuration.

    The global log settings are also used to control the logging of the Aerospike C client SDK which is included in the aerospike native add-on. The C client SDK log settings are global and cannot be set separately per Client instance.

Source:
Since:
  • v3.1.0
Example
const Aerospike = require('aerospike')

// INSERT HOSTNAME AND PORT NUMBER OF AEROSPIKE SERVER NODE HERE!
var config = {
  hosts: '192.168.33.10:3000',
}

Aerospike.setDefaultLogging({
  level: Aerospike.log.TRACE
})

Aerospike.connect(config, (error, client) => {
  if (error) {
    console.error('Failed to connect to cluster: %s', error.message)
    process.exit()
  } else {
    // client is ready to accept commands
    console.log("Connected. Now closing connection.")
    client.close()
  }
})
Parameters:
Name Type Description
log Object
Properties
Name Type Attributes Description
level Number <optional>

Log level; see module:aerospike.log for details.

file Number <optional>

File descriptor returned by fs.open() or one of process.stdout.fd or process.stderr.fd.

(static) setupGlobalCommandQueue(policy)

Configures the global command queue. (Disabled by default.)

Description:
  • Note that there is only one instance of the command queue that is shared by all client instances, even client instances connected to different Aerospike clusters. The setupGlobalCommandQueue method must be called before any client instances are connected.

Source:
See:
Parameters:
Name Type Description
policy CommandQueuePolicy

Set of policy values governing the behaviour of the global command queue.