0.1.2 • Published 6 years ago

adonis-nxl-gremlin v0.1.2

Weekly downloads
-
License
ISC
Repository
-
Last release
6 years ago

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])
0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago