Skip to content
Giraldo Rosales edited this page Apr 6, 2014 · 7 revisions

The methods below will call the server functions. User authentication for the server must first be configured in the orientdb-server-config.xml file. See OrientDB Wiki. To manipulate the actual database and records, see the document database api page. Additional details can be found on the OrientDB wiki page.

Table of Contents


Notes on Callbacks:

The methods are BlueBird promise objects and use the then and error methods for callbacks. Take a look at the Bluebird API for more details.

server.method().then(resultMethod).error(errorMethod);

//Example
server.method().then(function(results) {}).error(function(error) {});

***

When calling methods for the server, a connection must be opened using the connect method first. All other methods must be included in the callback.

###Configuration

####Server

  • host - Host name or IP of OrientDB. Default: "localhost"
  • port - Server port. Default: 2424.
  • username - Should be set in the users section of the orientdb-server-config.xml file. See OrientDB Wiki. Default: admin
  • password - Password for authentication. Default: admin,

***

###Connect to Server This is the first operation requested by the client when it needs to work with the server instance. It returns the session id of the client.

server.connect();
  • results - (object) Results
    • status - (numeric) If connection had an error. 0 = success, 1 = error.
    • sessionId - (numeric) Unique session id assigned to the connection.

Example

var OrientDB = require("node-orientdb");

var config = {
    //Server
    host:'localhost',
    port:2424,
    username:'admin',
    password:'admin',
    pool: {
      max: 10 // 1 by default
    }
};

var server = new OrientDB(config);

server.connect().then(function(results){
    console.log('Session ID: ' + results.sessionId);
);

###Shutdown Server Shut down the server. Requires shutdown permission to be set in orientdb-server-config.xml file.

server.shutdown();
  • results - NULL

###Get Config List

Get list of parameters set in the configuration. The configuration file is located in orientdb-server-config.xml, under:
<orient-server>
<properties></properties>
</orient-server>

server.config.list();
  • results - (object)
    • config - (array) List of key/value sets in the configuration.
      • param - (object) Parameter in the configuration.
        • key - (string) Parameter key.
        • value - (string) Parameter value.
    • count - (numeric) Number of parameters set in the configuration.

###Get Config Parameter

Get configuration parameters from

server.config.get(key);
  • key - (string) Configuration parameter to get.
  • results - (object)
    • value - (string) Value for the configuration key.

###Set Config Parameter

Set a configuration parameter

server.config.set(key, value);
  • key - (string) Configuration parameter to get.
  • value - (string) Value for the configuration key.
  • results - (boolean) True if set successfully, otherwise false.

###Create a New Database Creates a database in the remote OrientDB server instance.

server.create(databaseData);
  • databaseData - (object) Data to create a new database.

    • name - (string) Database name. Required.
    • type - (string) Database type. Valid values are: document or graph. Optional. Default: "document".
    • storage - (string) Storage type. Valid values are: local, plocal, or memory. Optional. Default: "local".
  • results - (boolean) Status of action. 1 = successful. 0 = unsuccessful.


###Drop/Delete a Database

Removes a database from the OrientDB Server instance. It returns nothing if the database has been deleted or throws a OStorageException if the database doesn't exists.

server.drop(database);
  • database - (string) Database object. Required.

    • name - (string) Database name. Required.
    • storage - (string) Storage type. Valid values are: local, plocal, or memory. Optional. Default: "local".
  • results - (boolean) Status of action. 1 = successful. 0 = unsuccessful.


###List Databases

server.list();
  • results - (array) An array of databases on the server.
    • obj - (object) Database object.
      • name - (string) Database name.
      • path - (string) Path to database.

###Check if Database Exist

Check whether a database exists

server.exist(databaseName, storageType);
  • databaseName - (string) Name of the database to check. Required.
  • storageType - (string) Database storage type. May be local, plocal, or memory. Optional. Default: local.
  • results - (boolean) True if database exists, otherwise false.

###Get Server Protocol

The server protocol version.

server.serverProtocolVersion

###Get Client Protocol

This NodeJS client protocol version.

server.currentProtocolVersion
Clone this wiki locally