JacksonTian / node-sequoiadb

Node.js Driver for SequoiaDB

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Node Sequoiadb

Node.js Driver for SequoiaDB

Installation

$ npm install sequoiadb --save

API

Connection

Create a connection to sequoiadb server:

var Connection = require('sequoiadb');
var conn = new Connection(11810, "ip", {
  user: "",
  pass: ""
});

Disconnect with sequoiadb server:

conn.disconnect([callback]);

Wait for connection ready:

conn.ready(function () {
  // TODO
});

All operation must be after db ready.

User

Create a user:

conn.createUser('user', 'pass', function (err) {
  // TODO
});

Remove a user:

conn.removeUser('user', 'pass', function (err) {
  // TODO
});

CollectionSpace

Create CollectionSpace in sequoiadb:

conn.createCollectionSpace("space_name", function (err, space) {
  // TODO
});

Get CollectionSpace in sequoiadb by name:

conn.getCollectionSpace("space_name", function (err, space) {
  // TODO
});

Check given space name whether exist:

conn.isCollectionSpaceExist("space_name", function (err, exist) {
  // TODO
});

Drop CollectionSpace:

conn.dropCollectionSpace("space_name", function (err) {
  // TODO
});

Get all CollectionSpaces:

conn.getCollectionSpaces(function (err, cursor) {
  // TODO
});

Cursor

Get current item:

cursor.current(function (err, item) {
  // TODO
});

Get next item:

cursor.next(function (err, item) {
  // TODO
});

Close cursor:

cursor.close(function (err) {
  // TODO
});

Collection

Create a Collection in CollectionSpace:

space.createCollection('collection_name', function (err, collection) {
  // TODO
});

Get a Collection from CollectionSpace by given name:

space.getCollection('collection_name', function (err, collection) {
  // TODO
});

Check a Collection whether exist:

space.isCollectionExist('collection_name', function (err, exist) {
  // TODO
});

Drop a Collection from a CollectionSpace:

space.dropCollection('collection_name', function (err) {
  // TODO
});

Document

Insert a document into Collection:

collection.insert({"name":"sequoiadb"}, function (err) {
  // TODO
});

Upsert a document into Collection:

collection.upsert({name: "sequoiadb"}, {'$set': {age: 26}}, {}, function (err) {
  // TODO
});

Bulk insert documents into Collection:

var insertors = [
  {name: "hi"},
  {name: "jack"}
];
collection.bulkInsert(insertors, 0, function (err) {
  // TODO
});

Query all document of Collection:

collection.query(function (err, cursor) {
  // TODO
});

Index

Create Index for collection:

var key = {
  "Last Name": 1,
  "First Name": 1
};
collection.createIndex("index_name", key, false, false, function (err) {
  // TODO
});

Get index with given name:

collection.getIndex("index_name", function (err, cursor) {
  // TODO
});

Get all indexes:

collection.getIndex(function (err, cursor) {
  // TODO
});

Or:

collection.getIndexes(function (err, cursor) {
  // TODO
});

Drop index:

collection.dropIndex('index_name', function (err) {
  // TODO
});

License

The Apache License 2.0

About

Node.js Driver for SequoiaDB

License:Apache License 2.0


Languages

Language:JavaScript 99.8%Language:Makefile 0.2%