This package has been deprecated

Author message:

this package has been deprecated

adonis-nxl-gremlin

0.1.2 • Public • Published

The demo project of Gremlin service provider for Microsoft Azure Document Graph Database. Compatible with AdonisJs 4.0.0.

Installation

npm

npm install adonis-nxl-gremlin --save

Usage

Create config file "gremlin.js" in config folder. The database informations can be found in Azure Portal.

'use strict'
 
module.exports = {
 
  host: [GREMLIN ENDPOINT],
  port: [PORT],
  prikey: [PRIMARY KEY],
  database: [DATABASE NAME],
  collection: [COLLECTION NAME]
 
}

Add service provider in start/app.js

const providers = [
  ...
  ...
  'adonis-nxl-gremlin/providers/GremlinProvider'
]

To catch an error

 
let res = await gremlin.addVertex([LABEL], prop)
          .catch(err => {
 
          })
 
await gremlin.addVertex([LABEL], prop)
  .then(res => {
   ...
  })
  .catch(err => { 
    ...
  }
try {
 
  let add_res = await gremlin.addVertex([LABEL], prop)
  let update_res = await gremlin.updateVertex([VERTEX ID], prop)
 
} catch (err) {
  ...  
}

Example

Add vertex

const gremlin = use('nxl-Gremlin')
 
let prop = {
  "email": "email@email.com",
  "pwd": "password"
}
 
let res = await gremlin.addVertex([LABEL], prop)

Update vertex (Label cannot be updated)

const gremlin = use('nxl-Gremlin')
 
let prop = {
  "email": "email@email.com",
  "pwd": "password"
}
 
let res = await gremlin.updateVertex([VERTEX ID], prop)

Drop vertex

const gremlin = use('nxl-Gremlin')
 
let res = await gremlin.dropVertex([VERTEX ID])

Get vertex by Id

const gremlin = use('nxl-Gremlin')
 
let res = await gremlin.getVertexById([ID])

Get vertex by label

const gremlin = use('nxl-Gremlin')
 
let res = await gremlin.getVertexByLabel([LABEL])

Get vertex by properties

const gremlin = use('nxl-Gremlin')
 
let res = await gremlin.getVertexByProperty([PROPERTY OBJECT])

Get next vertex

const gremlin = use('nxl-Gremlin')
 
let res = await gremlin.getNextVertexs([CURRENT VERTEX ID], [OUT EDGE LABEL])

Get next vertex by label

const gremlin = use('nxl-Gremlin')
 
let res = await gremlin.getNextVertexByLabel([CURRENT VERTEX ID], [NEXT VERTEX LABEL])

Drop vertex property

const gremlin = use('nxl-Gremlin')
 
let res = await gremlin.getNextVertexByLabel([CURRENT VERTEX ID], [PROPERTY NAME])

Get value of property by property name

const gremlin = use('nxl-Gremlin')
 
let res = gremlin.getValueByProperty([CURRENT VERTEX ID], [PROPERTY NAME])

Rename vertext property

const gremlin = use('nxl-Gremlin')
 
let res = await gremlin.renameProperty([CURRENT VERTEX ID], [CURRENT PROPERTY NAME], [NEW PROPERTY NAME])

Add edge

const gremlin = use('nxl-Gremlin')
 
let res = await gremlin.addEdge([EDGE LABEL], [FROM_VERTEX_ID], [TO_VERTEX_ID])
)

Drop edge

const gremlin = use('nxl-Gremlin')
 
let res = await gremlin.dropEdge([EDGE LABEL], [FROM_VERTEX_ID], [TO_VERTEX_ID])
)

Update edge

const gremlin = use('nxl-Gremlin')
 
let res = await gremlin.dropEdge([CURRENT EDGE LABEL], [NEW EDGE LABEL], [FROM_VERTEX_ID], [TO_VERTEX_ID])

Run custom gremlin query

const gremlin = use('nxl-Gremlin')
 
let res = await gremlin.run([GREMLIN QUERY])

Readme

Keywords

none

Package Sidebar

Install

npm i adonis-nxl-gremlin

Weekly Downloads

1

Version

0.1.2

License

ISC

Last publish

Collaborators

  • singha.w
  • wipu