Giter VIP home page Giter VIP logo

cayley.js's Introduction

cayley.js

NPM version

Cayley client for nodejs.

Install

$ npm install cayley --save

Usage

You just need to copy the code of Gremlin!

var cayley = require('cayley');

var client = cayley("http://localhost:64210/");

var g = graph = client.graph;
// or 
g = graph = client.g;

g.V().All(function(err, result) {
   // get result
});

g.V().GetLimit(5, function(err, result) {});

g.V("Humphrey Bogart").In("name").All(function(err, result) {});


// And you can create Morphism in you javascript code
var filmToActor = g.Morphism().Out("/film/film/starring").Out("/film/performance/actor");

g.V().Has("name", "Casablanca").Follow(filmToActor).Out("name").All(function(err, result) {});

When you want to query shape, g.type('shape') will return a new graph which return shape for query:

// to query shape
g = g.type('shape');
g.V().GetLimit(5, function(err, result) {
   // shape will return
});

Also simple write/delete APIs are implemented:

var client = cayley("http://localhost:64210/");
client.write([{
  subject: "Subject Node",
  predicate: "Predicate Node",
  object: "Object Node"
}], function(err, body, res) {

});

client.delete([{
  subject: "Subject Node",
  predicate: "Predicate Node",
  object: "Object Node"
}], function(err, body, res) {

});

cayley(host, [options])

options will be passed to request, so you can add settings like proxy, headers.

TODOs

  • mql api

Licence

MIT

cayley.js's People

Contributors

villadora avatar lwansbrough avatar craftzdog avatar

Stargazers

ExtraMile avatar Scott Beeker avatar Flávio HG avatar Matt Sears avatar  avatar Ali Torki avatar heineiuo avatar Sun Liren avatar  avatar  avatar Ulpian Morina avatar 席铭 avatar Michael Bortnick avatar Ahmet Simsek avatar ven avatar Moose avatar Jared Palmer avatar Sunny Gonnabathula avatar KPI6.com avatar Aniruddha Nath avatar Adrian Ottiker avatar Tudor Lapuste avatar  avatar Michael Staub avatar Andrei Sebastian Cîmpean avatar Jonas Hermsmeier avatar Athan avatar  avatar Yury Shulaev avatar Laurence Morin-Daoust avatar Chris Hart avatar Li Bin avatar Paul Le Cam avatar Matt avatar Ahmed avatar Alix Axel avatar Felipe Garcia Hernandez avatar Josh Sandlin avatar Kyriakos Chatzidimitriou avatar Simon Blee avatar R van der Feer avatar Ameen Soleimani avatar Chua Kiem Fai avatar Chi-Hsuan Huang avatar  avatar Samuel Deng avatar Huston Hedinger avatar  avatar Matteo Collina avatar Julian Bravard avatar Umar Hansa avatar  avatar  avatar Quang Van avatar Tay avatar Everton Yoshitani avatar Tristan Zajonc avatar

Watchers

 avatar James Cloos avatar Laurence Morin-Daoust avatar  avatar  avatar

cayley.js's Issues

How to have a cayley instance password protected?

How to have a cayley instance password protected?
Like in most db having a db account with a username and a password.
Is that done in a different layer, I mean in the perssitence layer that cayley depends on?
If so, how to connect it with this nodejs driver since this does not offer such options?

Basic querying doesn't seem to work

Using this test:

var log = require('winston');
var cayley = require('cayley');
var client = cayley("http://localhost:64210/", "v1");
var g = graph = client.graph;

client.write([{
  subject: 'subject',
  predicate: 'predicate',
  object: 'object'}
], function(err, body, res) {
  if (err) {
    log.info("error writing", err);
  } else {
    log.log('debug', 'Wrote');
  }
});

g.V('subject').Out('predicate').Tag('obj').All(function(err, result) {
  console.log("err", err);
  console.log("result", result);
})

I get null results in the last function, but the triple gets written to the database as visible using the HTTP user interface.

Maybe something in the latest cayley db broke this library?

add promise style if no callback provided

  1. choose one promise for default
  2. allow user to use other promise libs
  3. using promise when Promise is available in global?
  4. only take care how to create a promise
  • rsvp.js
  • q
  • bluebird
  • avow
  • when

Write triplet

I have configured cayley.js to use mongodb as backend. How do I go about writing/deleting a triplet through the client?

Tests seem to be failing for me

I'm not sure why

dascher-29223:cayley.js dascher1$ mocha


  cayley
    ✓ test All (44ms)
    ✓ test GetLimit
    1) test Vertex
    2) test V.In
    3) test V.Has
    4) test Morphism
    ✓ test Emit
    ✓ test type shape
    5) test write

  cayley
    ✓ test All
    ✓ test GetLimit
    6) test Vertex
    7) test V.In
    8) test V.Has
    9) test Morphism
    ✓ test Emit


  7 passing (15s)
  9 failing

  1) cayley test Vertex:
     Uncaught TypeError: Cannot read property 'length' of null
      at test/cayley.js:30:26
      at lib/v1/gremlin.js:133:9
      at Request._callback (lib/v1/gremlin.js:23:9)
      at Request.self.callback (node_modules/request/request.js:200:22)
      at Request.<anonymous> (node_modules/request/request.js:1041:10)
      at IncomingMessage.<anonymous> (node_modules/request/request.js:968:12)
      at endReadableNT (_stream_readable.js:913:12)
      at _combinedTickCallback (internal/process/next_tick.js:74:11)
      at process._tickCallback (internal/process/next_tick.js:98:9)

  2) cayley test V.In:
     Uncaught TypeError: Cannot read property 'length' of null
      at test/cayley.js:38:26
      at lib/v1/gremlin.js:133:9
      at Request._callback (lib/v1/gremlin.js:23:9)
      at Request.self.callback (node_modules/request/request.js:200:22)
      at Request.<anonymous> (node_modules/request/request.js:1041:10)
      at IncomingMessage.<anonymous> (node_modules/request/request.js:968:12)
      at endReadableNT (_stream_readable.js:913:12)
      at _combinedTickCallback (internal/process/next_tick.js:74:11)
      at process._tickCallback (internal/process/next_tick.js:98:9)

  3) cayley test V.Has:
     Uncaught TypeError: Cannot read property 'length' of null
      at test/cayley.js:46:26
      at lib/v1/gremlin.js:133:9
      at Request._callback (lib/v1/gremlin.js:23:9)
      at Request.self.callback (node_modules/request/request.js:200:22)
      at Request.<anonymous> (node_modules/request/request.js:1041:10)
      at IncomingMessage.<anonymous> (node_modules/request/request.js:968:12)
      at endReadableNT (_stream_readable.js:913:12)
      at _combinedTickCallback (internal/process/next_tick.js:74:11)
      at process._tickCallback (internal/process/next_tick.js:98:9)

  4) cayley test Morphism:
     Uncaught TypeError: Cannot read property 'length' of null
      at test/cayley.js:55:20
      at lib/v1/gremlin.js:133:9
      at Request._callback (lib/v1/gremlin.js:23:9)
      at Request.self.callback (node_modules/request/request.js:200:22)
      at Request.<anonymous> (node_modules/request/request.js:1041:10)
      at IncomingMessage.<anonymous> (node_modules/request/request.js:968:12)
      at endReadableNT (_stream_readable.js:913:12)
      at _combinedTickCallback (internal/process/next_tick.js:74:11)
      at process._tickCallback (internal/process/next_tick.js:98:9)

  5) cayley test write:
     Uncaught AssertionError: expected 'New Movie' to equal ''
      at test/cayley.js:97:20
      at lib/v1/gremlin.js:133:9
      at Request._callback (lib/v1/gremlin.js:23:9)
      at Request.self.callback (node_modules/request/request.js:200:22)
      at Request.<anonymous> (node_modules/request/request.js:1041:10)
      at IncomingMessage.<anonymous> (node_modules/request/request.js:968:12)
      at endReadableNT (_stream_readable.js:913:12)
      at _combinedTickCallback (internal/process/next_tick.js:74:11)
      at process._tickCallback (internal/process/next_tick.js:98:9)

  6) cayley test Vertex:
     TypeError: Cannot read property 'length' of null
      at test/thenable.js:29:26
      at _fulfilled (node_modules/q/q.js:834:54)
      at self.promiseDispatch.done (node_modules/q/q.js:863:30)
      at Promise.promise.promiseDispatch (node_modules/q/q.js:796:13)
      at node_modules/q/q.js:604:44
      at runSingle (node_modules/q/q.js:137:13)
      at flush (node_modules/q/q.js:125:13)
      at _combinedTickCallback (internal/process/next_tick.js:67:7)
      at process._tickCallback (internal/process/next_tick.js:98:9)

  7) cayley test V.In:
     Error: timeout of 5000ms exceeded. Ensure the done() callback is being called in this test.


  8) cayley test V.Has:
     Error: timeout of 5000ms exceeded. Ensure the done() callback is being called in this test.


  9) cayley test Morphism:
     Error: timeout of 5000ms exceeded. Ensure the done() callback is being called in this test.

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.