Socket
Book a DemoInstallSign in
Socket

neo4j-fiber

Package Overview
Dependencies
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

neo4j-fiber

Neo4j REST API Driver, with support of https and all DB's features

Source
npmnpm
Version
1.0.0-gamma.1.0.4
Version published
Weekly downloads
7
250%
Maintainers
1
Weekly downloads
 
Created
Source

Join the chat at https://gitter.im/VeliovGroup/ostrio-neo4jdriver

  • This driver was originally developed for Meteor, and it heavily depends from Fibers, so you required to wrap all code into Fiber
  • This package uses batch operations to perform queries, than means if you sending multiple queries to Neo4j in current event loop, all of them will be sent in closest (next) event loop inside of the one batch
  • This package was tested and works like a charm with GrapheneDB
  • To find more about how to use Cypher read Neo4j cheat sheet

Installation

npm install neo4j-fiber

Demo Apps

API:

Neo4jDB:

Neo4jNode:

Neo4jRelationship:

Neo4jTransaction:

Neo4jCursor:

Basic Usage Examples

Connect to Neo4j

db = new Neo4jDB 'http://localhost:7474', {
    username: 'neo4j'
    password: '1234'
  }

Run simple query

cursor = db.query 'CREATE (n:City {props}) RETURN n', 
  props: 
    title: 'Ottawa'
    lat: 45.416667
    long: -75.683333

console.log cursor.fetch()
# Returns array of nodes:
# [{
#   n: {
#     long: -75.683333,
#     lat: 45.416667,
#     title: "Ottawa",
#     id: 8421,
#     labels": ["City"],
#     metadata: {
#       id: 8421,
#       labels": ["City"]
#     }
#   }
# }]

# Iterate through results as plain objects:
cursor.forEach (node) ->
  console.log node
  # Returns node as Object:
  # {
  #   n: {
  #     long: -75.683333,
  #     lat: 45.416667,
  #     title: "Ottawa",
  #     id: 8421,
  #     labels": ["City"],
  #     metadata: {
  #       id: 8421,
  #       labels": ["City"]
  #     }
  #   }
  # }

# Iterate through cursor as `Neo4jNode` instances:
cursor.each (node) ->
  console.log node.n.get()
  # {
  #   long: -75.683333,
  #   lat: 45.416667,
  #   title: "Ottawa",
  #   id: 8421,
  #   labels": ["City"],
  #   metadata: {
  #     id: 8421,
  #     labels": ["City"]
  #   }
  # }

Create node

node = db.nodes()
node2 = db.nodes({property: 'value', property2: ['val', 'val2', 'val3']})

Get node by id

node = db.nodes(123)

Delete node

node.delete()

Create relationship

n1 = db.nodes()
relationship = db.nodes().to(n1, "KNOWS", {property: 'value'})

Delete relationship

relationship.delete()

Keywords

Neo4j

FAQs

Package last updated on 23 Sep 2015

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