Skip to content
Giraldo Rosales edited this page Apr 23, 2014 · 1 revision

Properties:

  • name (String) - Database name.
  • sessionId (Number) - The current session id.
  • storage (String) - Type of storage. Options: plocal, local, or memory. Default: "plocal".
  • type (String) - Type of database. Options: document, or graph. Default: "document".
  • username (String) - Authentication username.
  • password (String) - Authentication password.
  • dataSegments (Array) - A list of data segments.
  • transactionId (Number) - Transaction id.
  • server (Object) - Server object.
  • cluster (Object) - Cluster object.
  • class (Object) - Class object.
  • record (Object) - Record object.
  • vertex (Object) - Vertex object.
  • edge (Object) - Edge object.
  • index (Object) - Index object.


## Open ####Using an existing database ```javascript server.use(name); ```

Parameters:

  • name (String) - Database name.

Response:

  • database (Object) - Database object.

Example:

var db = server.use('mydb');
console.log('Using database: ' + db.name);

####Using an existing database with credentials

server.use(config);

Parameters:

  • name||config (String|Object) - Database name or configuration.
    • name (String) - Database name.
    • username (String) - Authentication username.
    • password (String) - Authentication password.

Response:

  • Database (Object) - Database object.

Example:

var db = server.use({
  name: 'mydb',
  username: 'admin',
  password: 'admin'
});
console.log('Using database: ' + db.name);


## Add Creating a new database in the OrientDB server instance. ```javascript server.create(config); ```

Parameters:

  • config (Object) - Database configuration.
    • name (String) - Name of the database. Required.
    • type (String) - Type of database. Options: document or graph. Default: "document".
    • storage (String) - Storage type. Options: plocal, local, memory. Default: "plocal".

Response:

  • Database (Object) - Database object.

Example:

server.create({
    name: 'mydb',
    type: 'graph',
    storage: 'plocal'
  })
  .then(function(db) {
    console.log('Created a database called ' + db.name);
  });


## Delete Removes a database from the OrientDB Server instance. ```javascript server.delete(config); ```

Parameters:

  • config (Object) - Database configuration.
    • name (String) - Name of the database. Required.
    • type (String) - Type of database. Options: document or graph. Default: "document".
    • storage (String) - Storage type. Options: plocal, local, memory. Default: "plocal".

Response:

  • results (Boolean) - If database exists, returns true. Otherwise false.

Example:

server.delete({
    name: 'mydb',
    type: 'graph',
    storage: 'plocal'
  })
  .then(function(results) {
    console.log('Delete a database: ' + results);
  });

Clone this wiki locally