npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

clusterpoint

v1.0.7

Published

Node.js API for Clusterpoint v4.* database

Readme

Node.JS API for Clusterpoint 4.*

Clusterpoint is a NoSQL document database known for its innovative Cloud-based distributed architecture, fast processing speed, and a flexible "pay as you use" pricing model. The database also features a developer-friendly API suitable for many popular modern programming languages, including Node.JS -- the specific API which is the focus of this document. Its full support for ACID-compliant transactions is a rarity among NoSQL databases, making the product useful for situations where data integrity is a must.

The recently introduced fourth edition of Clusterpoint added a unique JavaScript/SQL query language with computational capabilities, allowing you to create powerful queries to store, retrieve, and transform data. The Node.JS API is flexible enough to allow you to use either interface methods or raw JS/SQL queries to accomplish your database tasks. The decision to use either approach ultimately depends on programmer preference and the individual development scenario.

Node.JS API for Clusterpoint 4.*

Official Documentation

Documentation for the API can be found on the Clusterpoint website.

Getting Started

  1. Sign up for Clusterpoint – Before you begin, you need to sign up for a Clusterpoint account and retrieve your Clusterpoint credentials.
  2. Install the Node.JS API npm install clusterpoint

Quick Examples using CO library and Promises

'use strict';

//include Clusterpoint Library
var Clusterpoint = require('clusterpoint');
var co = require('co');


//Note, replace 'api-eu' with 'api-us', if you use US Cloud server
var config = {
	host      : 'api-eu.clusterpoint.com',
	account_id: 'ACCOUNT_ID',
	username  :   'USERNAME',
	debug     : true, // default = false
	port      : 443 // set custom port if using standalone version. Default port = 443
};

// In this example we will use a simple database named "bookshelf" which consists of books and book authors.

// create Clusterpoint main object
var cp = new Clusterpoint(config);

// connect to database
var bookshelfDB = cp.database('bookshelf');

// connect to collection using database connection
var authorsCollection = bookshelfDB.collection('authors');

// or one can connect straight to the collection like this
var booksCollection = cp.database('bookshelf').collection('books');

// Example using CO library
// CO = Generator based control flow goodness for nodejs and the browser, using promises, letting you write non-blocking code in a nice-ish way.
// install CO: npm install co
// https://github.com/tj/co
return co(function *() {

	// try to remove documents from both collections just for the purpose of this example
	console.log('select and delete all books');
	var response = yield booksCollection.limit(10000).get();
	var idsArr = [];
	for (let doc of response) {
		idsArr.push(doc._id);
	}

	if (idsArr.length > 0) {
		var response = yield booksCollection.deleteMany(idsArr);
	}

	console.log('select and delete all authors');

	var response = yield authorsCollection.limit(10000).get();
	var idsArr = [];
	for (let doc of response) {
		idsArr.push(doc._id);
	}
	if (idsArr.length > 0) {
		var response = yield authorsCollection.deleteMany(idsArr);
	}

	console.log('insert authors');

	// INSERT authors
	var documents = [
		{
			'_id' : 1,
			'name': 'John'
		},
		{
			'_id' : 2,
			'name': 'Fred'
		}
	];
	var response = yield authorsCollection.insertMany(documents);

	console.log('insert books');

	var documents = [
		{
			'_id'         : 1,
			'title'       : 'Book 1',
			'category'    : 'Science',
			'color'       : 'red',
			'availability': true,
			'author_id'   : 1,
			'price'       : 1,
			'deeper'      : {
				'foo': 1,
				'bar': 2
			}
		},
		{
			'_id'         : 2,
			'title'       : 'Book 2',
			'category'    : 'Fiction',
			'author_id'   : 2,
			'price'       : 2,
			'color'       : 'red',
			'availability': true
		}
	];
	var response = yield booksCollection.insertMany(documents);


	// list books with authors using JOIN (currently you have to use raw() function for JOINS)
	var response = yield booksCollection.raw('SELECT *, author.name ' +
		'FROM books ' +
		'LEFT JOIN authors AS author ON author._id == books.author_id');
	// console.log(response.getQuery());
	for (let book of response) {
		console.log(book.title + ' (' + book.author + ')');
	}

	// Another query builder example:
	var response = yield booksCollection.select(['color', 'price', 'category'])
		.where('color', 'red')
		.where('availability', true)
		.groupBy('category')
		.orderBy('price')
		.limit(5)
		.get();

	console.log(response.getQuery());
	console.log(response.results());

})
	.catch(function (err) {
		console.log('error:', err);
	});


// Example using Promises

booksCollection.limit(10000).get()
	.then(response => {
		// try to remove documents from both collections just for the purpose of this example
		var idsArr = [];
		for (let doc of response) {
			idsArr.push(doc._id);
		}

		return booksCollection.deleteMany(idsArr);
	})
	.then(response => {
		var documents = [
			{
				'_id'         : 1,
				'title'       : 'Book 1',
				'category'    : 'Science',
				'color'       : 'red',
				'availability': true,
				'author_id'   : 1,
				'price'       : 1,
				'deeper'      : {
					'foo': 1,
					'bar': 2
				}
			},
			{
				'_id'         : 2,
				'title'       : 'Book 2',
				'category'    : 'Fiction',
				'author_id'   : 2,
				'price'       : 2,
				'color'       : 'red',
				'availability': true
			}
		];
		return booksCollection.insertMany(documents);
	})
	.then(response => {
		return booksCollection.raw('SELECT books.title AS title, author.name AS name ' +
			'FROM books ' +
			'LEFT JOIN authors AS author ON author._id == books.author_id');
	})
	.then(response => {
		// console.log(response.getQuery());
		for (let data of response) {
			console.log(data.title + ' (' + data.name + ')');
		}
	})
	.catch(err => {
		console.log(err);
	});

Support, Feature Requests & Bug Reports

License

Node.JS API for Clusterpoint 4.* is open-sourced software licensed under the MIT license