forked from codemix/oriento
-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Giraldo Rosales edited this page Apr 23, 2014
·
15 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.
## Initialize the Server First, require the library. ```javascript var Oriento = require('oriento'); ```
### Basic Configuration Now, we call the `Oriento` function, passing in our connection options. ```javascript var server = new Oriento({ host: 'localhost', port: 2424, username: 'root', password: 'yourpassword' }); ``` `server` is now an instance of `Oriento.Server`. it provides methods for creating, listing, dropping and using databases.
### Connection Pool Configuring the client to use a connection pool. By default Oriento uses one socket per server, but it is also possible to use a connection pool. You should carefully benchmark this against the default setting for your use case, there are scenarios where a connection pool is actually slightly worse for performance than a single connection. ```javascript var server = new Oriento({ host: 'localhost', port: 2424, username: 'root', password: 'yourpassword', pool: { max: 10 // 1 by default } }); ```
## Methods The methods are BlueBird promise objects and use the then and error methods for callbacks. Take a look at the [Bluebird API](https://github.com/petkaantonov/bluebird/blob/master/API.md) for more details. ```javascript server.method().then(resultMethod).error(errorMethod);
// Example: server.method() .then(function(results) { console.log('Success with results.'); }) .error(function(error) { console.log('Error with message.'); });