New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

orientdb-rest-api

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

orientdb-rest-api

A node.js driver for OrientDB using the OrientDB RESTful HTTP protocol

  • 1.0.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-94.74%
Maintainers
1
Weekly downloads
 
Created
Source

orientdb-rest-api

A Node.js driver to talk to the OrientDB REST API

Very basic http wrapper using axios based on node-orient-http and tested on OrientDb 2.2.31

Install

npm install orientdb-rest-api

Basic Usage

const OrientDB=require('orientdb-rest-api');

const db = new OrientDB({
  user: 'root',
  password: 'root_passwd',
  host: 'http://localhost:2480',
  database: 'GratefulDeadConcerts',
})

db.connect().then(async ()=>{
  const result=await db.query('select * from V where name = ?',["Batman"])
  console.log(result)
}).catch(err=>{
  console.error(err.message)
})

Command and Query

db.command('insert into V set name = ?', ["Batman"]).then(async ()=>{
  // named parameters
  const queryResult=await db.query('select * from V where name = :name', null, null, {
    name: "Batman"
  })
  console.log(queryResult)
}).catch((err)=>console.error(err))

Methods

// general api
db.[get|post|put|delete](command, queryParams, postBody).then(successHandler).catch(errorHandler)

db.post('document', null, { '@class': 'V', name: 'Gustavo Salome'}).then(successHandler).catch(errorHandler)

db.delete('document', '9:1').then(successHandler).catch(errorHandler)

// or specific commands
db.command('insert into V set name = "Batman"').then(successHandler).catch(errorHandler)

db.query('select * from V where name = "Batman"').then((res)=>{
  console.log(res)
}).catch(err=>{
  console.log(err.message)
})

db.language('gremlin').query("g.V('@class', 'User')").then(successHandler2).catch(errorHandler2)

Events

const db = new OrientDB({
  user: 'root',
  password: 'root_passwd',
  host: 'http://localhost:2480',
  database: 'GratefulDeadConcerts',
})

db.connect()
// once connected
db.once('connected', (db)=>{
  console.log('yes! connected')
})
// on error
db.on('error',err=>{
  console.log('err', err.message)
})

Example

const OrientDB=require ('orientdb-rest-api')
const db=new OrientDB({
  user: 'root',
  password: 'password',
  host: 'http://localhost:2480',
  database: 'GratefulDeadConcerts',
})

db.connect().then(async ()=>{
  let res
  res=await db.command('insert into V set name = ?', ["Batman"])
  console.log(res)
  res=await db.query('select * from V where name = :name', {
    name: "Batman"
  })
  console.log(res)
  res=await db.command('select * from V where name = ?', ["Batman"], 1)
  console.log(res)
  res=await db.delete('document', res.result[0]['@rid'])
  console.log(res.status)
}).catch(err=>{
  if(!err)
    console.error('err')
  else if(err.response && err.response.data)
    console.error(err.response.data)
  else if(err.message)
    console.error(err.message)
  else
    console.error(err)
})

Api

See OrientDB-REST API for more docs.

Erros

Listening for error events

db.on('error',err=>{
  console.log('err', err)
})

See Axios Error Handling for more information

Changelog

1.0.0

  • First Release

Keywords

FAQs

Package last updated on 16 Dec 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc