Giter VIP home page Giter VIP logo

ostrio-neo4jdriver's Introduction

Wrapper for node-neo4j by The Thingdom to be used with Meteor apps

See also Isomorphic Reactive Driver.

Install to meteor

meteor add ostrio:neo4jdriver

Usage

npm install neo4j
In your code:

Create file in ./server/lib/Neo4jDriver.js

this.N4JDB = new Meteor.Neo4j(/* http://username:[email protected] */); //From this point N4JDB variable available everywhere in your project

Next, just use it.

Examples:
var node = N4JDB.createNode({hello: 'world'});     // instantaneous, but...
node.save(function (err, node) {    // ...this is what actually persists.
    if (err) {
        console.error('Error saving new node to database:', err);
    } else {
        console.log('Node saved to database with id:', node.id);
    }
});
/*
 * Create user node with _id
 */
Accounts.onCreateUser(function(options, user) {

    N4JDB.query('CREATE (:User {_id:"' + user._id + '"})', null, function(err, res){
        if(error){
            //handle error here
        }
    });
});
###
This example in coffee
Here we create some group and set our user as it's owner
Next, we add relation :owns from owner to newly created group in one query
###
groupId = GroupsCollection.insert title: 'Some Group Title', (error) ->
    error if error 
        #handle error here

N4JDB.query 'Match (o:User {_id:"' + Meteor.userId() + '"}) ' + 
            'CREATE (g:Group {_id:"' + groupId + '", owner: "' + Meteor.userId() + '", active: true}) ' + 
            'CREATE (o) -[:owns]-> (g)', null, (error, res) ->
    error if error
        #handle error here
###
Register catch all callback
Note - you may register as many callbacks as you need
@param query {string} - Cypher query
@param opts {object} - A map of parameters for the Cypher query 
###
N4JDB = new Neo4j()
N4JDB.listen (query, opts) ->
    console.log query, opts

For more info see: node-neo4j Code licensed under Apache v. 2.0: node-neo4j License


Testing & Dev usage

Local usage
  • Download (or clone) to local dir
  • Stop meteor if running
  • Run mrt link-package [*full path to folder with package*] in a project dir
  • Then run meteor add ostrio:neo4jdriver
  • Run meteor in a project dir
  • From now any changes in ostrio:neo4jdriver package folder will cause rebuilding of project app

ostrio-neo4jdriver's People

Contributors

dr-dimitru avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.