• Stars
    star
    198
  • Rank 196,898 (Top 4 %)
  • Language
    JavaScript
  • License
    Apache License 2.0
  • Created almost 11 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Node.js client for the Aerospike database

Aerospike Node.js Client travis codecov npm downloads

The Aerospike Node.js client is a Node.js add-on module, written using V8.

The client is compatible with Node.js 20 (LTS), 19, 18 (LTS), 16 (LTS). It supports the following operating systems:

  • RHEL 8/9
  • Debian 10 (x86_64 architecture only)
  • Debian 11
  • Amazon Linux 2023
  • Ubuntu 20.04/22.04 (Focal Fossa, Jammy Jellyfish)
  • Many Linux distributions compatible with one of the above OS releases.
  • macOS versions 11/12/13 are also supported. (Node.js 14 install unavailable on M1 Mac systems)

The client is compatible with arm64, aarch64, and x86_64 architectures.

The Aerospike Node.js client supports all Node.js LTS releases. To download and install the latest stable version of Node.js, visit nodejs.org.

Install the necessary "development tools" and other libraries to build the client software. Reference various docker files in the repository under the docker directory for more information.

Installation

The Aerospike Node.js client is an add-on module that uses the Aerospike C client. The installation will attempt to install the pre-built binaries including dependent C client.

You can install the Aerospike Node.js client like any other Node.js module.

Primer on Node.js Modules

Node.js modules are containers of JavaScript code and a package.json, which defines the module, its dependencies and requirements. Modules are usually installed as dependencies of other Node.js applications or modules. The modules are installed in the application's node_modules directory, and can be utilized within the program by requiring the module by name.

npm Registry Installations

To install aerospike as a dependency of your project, in your project directory run:

npm install aerospike

To add aerospike as a dependency in package.json, run:

npm install aerospike --save-dev

To require the module in your application:

const Aerospike = require('aerospike')

Usage

The following is very simple example how to create, update, read and remove a record using the Aerospike database.

const Aerospike = require('aerospike')

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

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

Aerospike.connect(config)
  .then(client => {
    const bins = {
      i: 123,
      s: 'hello',
      b: Buffer.from('world'),
      d: new Aerospike.Double(3.1415),
      g: Aerospike.GeoJSON.Point(103.913, 1.308),
      l: [1, 'a', {x: 'y'}],
      m: {foo: 4, bar: 7}
    }
    const meta = { ttl: 10000 }
    const policy = new Aerospike.WritePolicy({
      exists: Aerospike.policy.exists.CREATE_OR_REPLACE,
      // Timeouts disabled, latency dependent on server location. Configure as needed.
      socketTimeout : 0, 
      totalTimeout : 0
    })

    return client.put(key, bins, meta, policy)
      .then(() => {
        const ops = [
          Aerospike.operations.incr('i', 1),
          Aerospike.operations.read('i'),
          Aerospike.lists.append('l', 'z'),
          Aerospike.maps.removeByKey('m', 'bar')
        ]

        return client.operate(key, ops)
      })
      .then(result => {
        console.log(result.bins) // => { i: 124, l: 4, m: null }

        return client.get(key)
      })
      .then(record => {
        console.log(record.bins) // => { i: 124,
                                 //      s: 'hello',
                                 //      b: <Buffer 77 6f 72 6c 64>,
                                 //      d: 3.1415,
                                 //      g: '{"type":"Point","coordinates":[103.913,1.308]}',
                                 //      l: [ 1, 'a', { x: 'y' }, 'z' ],
                                 //      m: { foo: 4 } }
      })
      .then(() => client.close())
  })
  .catch(error => {
    console.error('Error: %s [%i]', error.message, error.code)
    if (error.client) {
      error.client.close()
    }
  })

Prerequisites

RHEL/CentOS

To install library prerequisites using yum:

sudo yum group install "Development Tools" 
sudo yum install openssl openssl-devel
sudo yum install python3 python3-devel

Alpine Linux

apk add build-base \
    linux-headers \
    bash \
    libuv-dev \
    openssl-dev \
    lua5.1-dev \
    zlib-dev \
    git \
    python3

Amazon Linux

yum groupinstall "Development Tools"
yum install openssl openssl-devel
yum install python3 python3-devel

Debian

To install library prerequisites using apt-get:

sudo apt -y install software-properties-common
sudo apt -y install build-essential
sudo apt -y install libssl-dev
sudo apt -y install libarchive-dev cmake rsync curl libcurl4-openssl-dev zip
sudo apt -y install python3 python3-dev python3-pip
sudo apt install zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev \
    libsqlite3-dev libreadline-dev libffi-dev libbz2-dev -y
sudo apt -y install wget libtool m4 automake

Ubuntu

To install library prerequisites using apt:

sudo apt install g++ libssl libssl-dev zlib1g-dev

macOS

Before starting with the Aerospike Nodejs Client, verify that you have the following prerequisites:

  • macOS 10.8 or greater.
  • Xcode 5 or greater.

OpenSSL Library OpenSSL is needed to build the Aerospike C Client. If downloading from NPM at version 5.6.0 or later, you will not need to have OpenSSL installed to use the Aerospike Nodejs Client. If you are using version 5.5.0 and below, you will need to do some additional linking to use the client, which is specified below.

We recommend using brew to install OpenSSL:

brew install openssl

For a Mac using ARM architecture, OpenSSL should be linked as shown below:

# When building from source before version 5.6 with openssl@3
sudo ln -s /opt/homebrew/opt/openssl@3/ /usr/local/opt/openssl;
# link here if before version 5.6.0
sudo ln -s /opt/homebrew/opt/openssl@3/ /usr/local/opt/openssl@3;

# When building from source with [email protected]
sudo ln -s /opt/homebrew/opt/[email protected]/ /usr/local/opt/openssl;
# link here if before version 5.6.0 with [email protected]
sudo ln -s /opt/homebrew/opt/[email protected]/ /usr/local/opt/[email protected];

For a Mac using X86 architecture, OpenSSL should be linked as shown below:

# When building from source before version 5.6 with [email protected]
sudo ln -s /opt/homebrew/opt/[email protected]/ /usr/local/opt/openssl;
# link here if before version 5.6.0 with [email protected]
sudo ln -s /opt/homebrew/opt/[email protected]/ /usr/local/opt/[email protected];

Before version 5.6.0, you may need to some add some variables to your profile for OpenSSL to be found.

export PATH="/usr/local/bin/:/usr/local/opt/openssl/bin:$PATH"
export LDFLAGS="-L/usr/local/opt/openssl/lib"
export CPPFLAGS="-I/usr/local/opt/openssl/include"  
export EXT_CFLAGS="-I/usr/local/opt/openssl/include"
# Make sure to source the changes to your shell profile
source ~/.bashrc
source ~/.profile
source ~/.zshrc

For 4x client support, install [email protected] version.

LIBUV Library

Libuv is needed to build the Aerospike C Client. If downloading from NPM at version 5.6.0 or later, you will not need to have Libuv installed to use the Aerospike Nodejs Client. If you are using version 5.5.0 and below, you will need to do some additional linking to use the client, which is specified below.

We recommend using brew to install Libuv:

brew install libuv

For a Mac using ARM architecture, Libuv should be linked as shown below:

# When building from source before version 5.6
sudo ln -s /opt/homebrew/opt/libuv/ /usr/local/opt/libuv;

Git Repository Installations

When using a cloned repository, install aerospike as a dependency of your application. Instead of referencing the module by name, you reference it by path.

To clone the repository use the following command:

  git clone --recursive [email protected]:aerospike/aerospike-client-nodejs.git

Building dependancy C client

Make sure to build the C client before doing npm install variants Run the following commands to build the C client:

  ./scripts/build-c-client.sh

Building and installing Node.js client

To install the module as a dependency of your application, run the following in the application directory:

npm install --unsafe-perm --build-from-source

To require it in the application:

const Aerospike = require('aerospike')

Documentation

Access the client API documentation at: https://docs.aerospike.com/apidocs/nodejs. This documentation is built from the client's source using JSDocs v3 for every release.

The API docs also contain a few basic tutorials:

A variety of additional example applications are provided in the examples directory of this repository.

Access backward incompatible API changes by a release at: https://developer.aerospike.com/client/nodejs/usage/incompatible.

API Versioning

The Aerospike Node.js client library follows semantic versioning. By Aerospike versioning guidelines, changes which may break backwards compatibility are indicated by an increase in the major version number. Minor, or patch releases, which are incremented only the second and third version number, are always backwards compatible.

Tests

The client includes a comprehensive test suite using Mocha. The tests can be found in the repository under test directory.

Before running the tests, you need to update the dependencies:

npm update

To run all the test cases:

npm test

Note: make sure your server has TTL enabled for the test namespace (Namespace Retention Configuration) to allow all tests to run correctly.

To run the tests and also report on test coverage:

npm run coverage

Benchmarks

Benchmark utilities are provided in the repository under benchmarks directory. See the benchmarks/README.md for details.

License

The Aerospike Node.js Client is made available under the terms of the Apache License, Version 2, as stated in the LICENSE file.

Individual files may be made available under their own specific license, all compatible with Apache License, Version 2. Refer to individual files for details.

More Repositories

1

aerospike-server

Aerospike Database Server – flash-optimized, in-memory, nosql database
C
1,036
star
2

aerospike-client-go

Aerospike Client Go
Go
432
star
3

aerospike-client-java

Aerospike Java Client Library
Java
236
star
4

act

Aerospike Certification Tool
C
188
star
5

aerospike-server.docker

Dockerfiles for Aerospike Server
Shell
141
star
6

aerospike-client-python

Aerospike Python Client
Python
131
star
7

aerospike-client-c

Aerospike C Client
C
95
star
8

aerospike-kubernetes-operator

Kubernetes operator for the Aerospike database
Go
91
star
9

aerospike-client-rust

Rust client for the Aerospike database
Rust
82
star
10

aerospike-client-csharp

Aerospike C# Client Library
C#
70
star
11

aerospike-client-ruby

Ruby client for the Aerospike database
Ruby
60
star
12

aerospike-kubernetes

Mustache
51
star
13

aerospike-common

Common Library
C
47
star
14

aerospike-loader

Aerospike Data Loader
Java
39
star
15

aerospike-admin

Aerospike Administration tool: allows operations to view vital stats from the aerospike server from the command line.
Python
38
star
16

aerospike-prometheus-exporter

Monitoring suite for the Aerospike DB
Go
36
star
17

aerospike-monitoring

Python
33
star
18

aerospike-vector-search-examples

aerospike-vector-search-examples
Python
29
star
19

aerospike-jdbc

Minimalist JDBC driver for Aerospike
Java
27
star
20

asmalloc

Aerospike Memory Allocation Tracking Tool
C
26
star
21

aws-cloudformation

AWS CloudFormation scripts related to Aerospike
25
star
22

aerospike-tools-backup

Aerospike backup and restore utility
C
25
star
23

jemalloc

Aerospike Fork of the JEMalloc Memory Allocator
C
21
star
24

gommander

Go library to manage multiple servers over SSH
Go
18
star
25

aerospike-tools.docker

Aerospike Tools Dockerfile
Dockerfile
18
star
26

aerolab

Quickly spin up Aerospike clusters on docker or in AWS
Go
17
star
27

aerospike-kubernetes-enterprise

Shell
17
star
28

java-object-mapper

The Java Object Mapper is a simple, light-weight framework used to map POJOs to the Aerospike database. Using simple annotations or a configuration YAML file to describe how to map the data to Aerospike, the project takes the tedium out of mapping the data through the powerful, low level interface.
Java
17
star
29

aerospike-benchmark

A tool to benchmark the Aerospike Database.
C
15
star
30

aerospike-rest-gateway

REST client for the Aerospike database
Java
15
star
31

aerospike-server-enterprise.docker

Dockerfile for Aerospike Server Enterprise Edition
Shell
15
star
32

aerospike-mod-lua

Lua Interface Module for Aerospike Server and C Client
C
12
star
33

aerospike-backup-service

Aerospike Backup Service
Go
12
star
34

aerospike-document-lib

Aerospike Java Document API
Java
11
star
35

aerospike-client-java-reactive

Reactive programming interfaces for the Aerospike Java client
Java
9
star
36

aerospike-lua-core

Aerospike Lua Core Library
Lua
9
star
37

php-client

Aerospike Client for PHP 8
Rust
9
star
38

backup-go

A go library for backup and restore
Go
9
star
39

luajit

Aerospike Fork of the Lua JIT (Just-In-Time Compiler) http://luajit.org/
C
8
star
40

aerospike-connect-inbound-sdk

Inbound SDK for custom transforms or other plugins
Java
8
star
41

aerospike-dev-notebooks.docker

Repo for a docker image with Server, Jupyter, Python client, Tools and Notebooks
Jupyter Notebook
8
star
42

asmt

Backup & restore shmem indexes.
C
7
star
43

aerospike-tools-validation

C
7
star
44

aerospike-management-lib

A library to hold aerospike management and operations tasks.
Go
6
star
45

lua-bac

The Lua programming language with CMake based build
C
6
star
46

aerospike-docker-swarm

Python
6
star
47

graph-synth

Graph Synthesis Tool
Java
5
star
48

aql

The Aerospike Quick Look data browsing utility.
C
5
star
49

trino-aerospike.docker

Trino with the Aeropsike connector Docker Image
Shell
5
star
50

aerospike-client-rest-kubernetes

Aerospike REST client Helm chart for Kubernetes
Smarty
5
star
51

aerospike-elk

Starting point for using Aerospike with ElasticSearch / LogStash / Kibana for log file analysis.
5
star
52

document-lib-python

Python
5
star
53

aerospike-telemetry-agent

Aerospike Telemetry Agent: Anonymized Usage Data Collector.
Python
4
star
54

asconfig

A CLI tool for managing Aerospike configuration files.
Go
4
star
55

s2-geometry-library

C++
4
star
56

aerospike-connect-outbound-sdk

An outbound SDK for creating custom transforms for streaming connectors.
Java
3
star
57

tools-common-go

Common library used in tools golang projects.
Go
3
star
58

avs-client-go

πŸš€βž‘οΈπŸ”πŸΉ
Go
3
star
59

asvec

Aerospike Vector CLI
Go
3
star
60

aerospike-kubernetes-init

Go
2
star
61

kubernetes-operator

Website for the Aerospike Kubernetes Operator
JavaScript
2
star
62

helm-charts

Public helm charts for Aerospike
Shell
2
star
63

avs-client-python

πŸš€βž‘οΈπŸ”πŸ Aerospike Vector Search Client for Python
Python
2
star
64

schemas

Location for public aerospike schemas (json / yaml / xml / etc)
2
star
65

cloud-qualification

Scripts and instructions to run benchmarks/tests on cloud environments.
Python
2
star
66

aerospike-kubernetes-operator-ctl

Aerospike kubernetes operator command line tool
Go
1
star
67

secret-agent-client-c

C
1
star
68

azure-resource-manager

Shell
1
star
69

cf-service-broker-tile

Package up the Aerospike Service Broker into a Pivotal Cloud Foundry tile
Python
1
star
70

aerospike-database-recovery

Aerospike Database Recovery Documentation
Shell
1
star
71

cf-managed-service-tile

Cloud Foundry Managed Service for Aerospike
Shell
1
star
72

aerospike-net-extensions

Aerospike .NET Extensions [IDistributedCache]
C#
1
star
73

aerospike-proxy-client-sdk

Aerospike Proxy Client SDK for building clients
Kotlin
1
star
74

movement

Parallel Dataflow System
Java
1
star
75

abseil-cpp

C++
1
star