orientdb-rest-api
A Node.js driver to talk to the OrientDB REST API for node and the browser Also works with electron and react-native
Very basic http wrapper using superagent based on node-orient-http and tested on OrientDb 2.2.31
Install
npm install orientdb-rest-api
Basic Usage
const OrientDB=; const db = user: 'root' password: 'root_passwd' host: 'http://localhost:2480' database: 'GratefulDeadConcerts' db
Query and Command query
Syntax:
dbdb
Examples:
db
Response will be something like:
Methods
All methods return a Promise
See superagent for more information about the response and errors
Connection
db.connect()
returns boolean
db.disconnect()
returns boolean
Rest commands:
db.get(command, queryParams)
returns object
db.delete(command, queryParams)
returns boolean
db.head(command, queryParams)
returns boolean
db.post(command, queryParams, postBody)
returns object
db.put(command, queryParams, postBody)
returns object
db.patch(command, queryParams, postBody)
returns object
Custom commands
db.query(query, [paramenters, limit, fetchplan])
returns object
containing the result of the query
db.command(query, [paramenters, limit, fetchplan])
returns object
|boolean
containing the result of the command
db.insert(className, data)
returns boolean
shortcut as db.post('document', null, data)
and set '@class' property of data
db.queryOne(query, paramenters, fetchplan)
returns Object
|null
shortcut for setting limit 1 and return either first result or null
Helpers
db.getDateTimeFormatted([fromDate])
return string
returns a datetime formatted date. fromDate is optional, if not set, it will use current datetime
db.getDateFormatted([fromDate])
same as above
Examples:
// createdb // deleting, should return truedb // create as command, should return the new recorddb db
Language
dblanguage'gremlin'
See OrientDB-REST API for a full list of rest commands
Events
const db = user: 'root' password: 'root_passwd' host: 'http://localhost:2480' database: 'GratefulDeadConcerts' dbdb// once connecteddb// on any errordbdb
Example
const OrientDB=const db= user: 'root' password: 'password' host: 'http://localhost:2480' database: 'GratefulDeadConcerts'const config=const db=configdbdbdbdb
Api
See OrientDB-REST API for more docs.
Erros
Listening for error events
dbdb
See SuperAgent Error Handling for more information
Config
user: 'root' password: 'root_passwd' host: 'http://127.0.0.1:2480' database: 'GratefulDeadConcerts' language: 'sql' timeout: 1000*5
Changelog
1.1.0
- Changed from axios to superagent
1.0.0
- First Release