masumsoft / express-cassandra

Cassandra ORM/ODM/OGM for NodeJS with support for Apache Cassandra, ScyllaDB, Datastax Enterprise, Elassandra & JanusGraph.
http://express-cassandra.readthedocs.io
GNU Lesser General Public License v3.0
227 stars 67 forks source link

janusgraph support doesn't work #204

Closed shanequint closed 4 years ago

shanequint commented 4 years ago

I have set up a node.js route that executes the express-cassandra with the ormOptions: manageGraphs: true.

I get the error message "

To use janus graph features, set manageGraphs to true in ormOptions

".

In the get_gremlin_client function: if (!this._properties.gremlin_client) { throw (new Error('To use janus graph features, setmanageGraphsto true in ormOptions')); } return this._properties.gremlin_client; };

It looks to be checking the gremlin_client property instead of the properties.init.manageGraphs. This makes the creating of a Vertex within the supplied keyspace fail.

Am I missing some configuration?

Here is the sample I am attempting.

`const router = require('express').Router(); const ExpressCassandra = require('express-cassandra');

router.post('/', (req, res, next) => { var models = ExpressCassandra.createClient({ clientOptions: { contactPoints: ['127.0.0.1'], protocolOptions: { port: 9042 }, keyspace: req.body.graphName, queryOptions: {consistency: ExpressCassandra.consistencies.one} }, ormOptions: { defaultReplicationStrategy: { class: 'SimpleStrategy', replication_factor: 1 }, migration: 'alter', manageGraphs: true } });

var MyModel = models.loadSchema('Person', { fields:{ Id : 'int', name : 'text', surname : 'text', age : 'int', created : 'timestamp', }, key:['Id'] });

MyModel.createVertex({ Id: 1234, name: 'john', age: 32 }, (err, response) => { if (err) throw err; // response contains the created vertex object // response.id contains vertex id // response.properties contains it's properties return response; }); });

module.exports = router;`

masumsoft commented 4 years ago

@shanequint what version of janusgraph and gremlin package are you using?

shanequint commented 4 years ago

I'm running Janusgraph 0.3.1 with gremlin CLV installed with express_cassandra which I think is 2.6.0?

shanequint commented 4 years ago

It looks like I had an old version of gremlin-javascript CLV in my package.json. Even though I tried to upgrade it. I finally blew away my node_modules, removed the old version from package.json and did a re-install. Now I have version 3.4.3 of gremlin-javascipt CLV. I will test more tomorrow. Thanks

masumsoft commented 4 years ago

The gremlin package used by express-cassandra is 2.6.0. If janusgraph is used, then for now it is advised to use that specific gremlin version with it which is documented now.