Skip to content
Giraldo Rosales edited this page Jan 27, 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.

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

//Example
orientServer.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

  • server_host - Host name or IP of OrientDB. ie: "localhost"
  • server_port - Server port. Default server port is: 2424.
  • server_username - Should be set in the users section of the orientdb-server-config.xml file. See OrientDB Wiki.
  • server_password - 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.

orientServer.connect();
  • results - (object) Results
    • sessionId - (numeric) Session id.

Example

var orientdb = require("node-orientdb");
var Server   = OrientDb.Server;

var dbConfig = {
    //Server
    server_host:'localhost',
    server_port:2424,
    server_username:'admin',
    server_password:'admin',

    //Database
    database_name:'social',
    database_username:'admin',
    database_password:'admin',
    database_type: "document", //Optional. Default: document.
    database_storage: "local" //Optional. Default: local.
};

var orientServer = new Server(dbConfig);

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

    //List databases
    orientServer.list()
        .then(function(results) {
            orientServer.close();
            console.log(results);
        })
        .error(function(error) {
            orientServer.close();
            console.log(error);
        });
);

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

orientServer.shutdown(username, password);
  • username - (string) Admin username.
  • password - (object) Password for user.
  • 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>

orientServer.configList();
  • 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

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

###Set Config Parameter

Set a configuration parameter

orientServer.configSet(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.

orientServer.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.

orientServer.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

orientServer.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

orientServer.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.

orientServer.serverProtocolVersion

###Get Client Protocol

This NodeJS client protocol version.

orientServer.currentProtocolVersion

Clone this wiki locally