Skip to content

aerojs/aero-aerospike

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

aero-aerospike

This client can be used as a standalone package (without using Aero). It is a lightweight wrapper built on top of the official node.js client. All API calls return bluebird promises.

Installation

Add aero-aerospike to dependencies in your package.json:

"dependencies": {
	"aero-aerospike": "*"
}
npm install

Usage with Aero

Add the database configuration to your config.json:

"database": {
	"namespace": "test"
}

You can also specify "host": "127.0.0.1:3000" if needed.

Now you can subscribe to the event database ready:

app.on('database ready', db => {
	db.get('Users', 'test').then(console.log)
})

API

Creating a client

let aerospike = require('aero-aerospike')

let db = aerospike.client({
	host: '127.0.0.1:3000',
	namespace: 'Test'
})

db.connect()

aerospike.client

let db = aerospike.client({
	host: '127.0.0.1:3000',
	namespace: 'Test'
})

The configuration parameters are directly handed over to the Aerospike.client constructor of the official aerospike node library. Therefore you can also specify hosts, log, policies and so on. host is a shortcut notation added by this library. namespace specifies the namespace you want to operate on.

get

db.get('Users', 'key')

set

db.set('Users', 'key', {
	name: 'Will Smith'
})

Does not delete existing properties if the record already exists. Only updates the name property.

remove

db.remove('Users', 'key')

forEach

db.forEach('Users', user => console.log(user.name))

filter

db.filter('Users', user => user.isAdmin)

all

db.all('Users')

getMany

db.getMany('Users', ['key 1', 'key 2', 'key 3'])

ready

db.ready.then(() => 'Connected to database!')

connect

db.connect() === db.ready

db.connect().then(() => 'Connected to database!')

About

☁️ Simple API for Aerospike.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published