Code Monkey home page Code Monkey logo

Comments (3)

batwicket avatar batwicket commented on June 9, 2024

The gremlin client sets language to gremlin-groovy, and the titan tutorial says it is using that language:

gremlin> theseus = graph.addVertex('human')
==>v[3328]
gremlin> theseus.property('name', 'theseus')
==>null
gremlin> cerberus = g.V().has('name', 'cerberus').next()
==>v[2816]
gremlin> battle = theseus.addEdge('battled', cerberus, 'time', 22)
==>e[7eo-2kg-iz9-268][3328-battled->2816]

I tried:

`gremlin`g.addV(label, 'god')\ntheseus=g.addV(label, 'human')\ncerberus=g.V().hasLabel('god').next()\ng.V().count()`

but the count was 0. The vertices were not created before the count(). So I tried:

    return this.gremlin`cerberus=g.addV(label, 'god').next()`
        .then(() => {
            return this.gremlin`theseus=g.addV(label, 'human')`
        })
        .then(() => {
            return this.gremlin`g.V().count()`;
        })
        .then(count => {
            console.log('count: ', count);
            return this.gremlin`g.V().hasLabel('human').addE('battled', cerberus, 'time', 22)`;
        })

The count is now ok, but it says 'no such property: cerberus for class: Script62'.

I've probably missed something.. it seems like it should be a common task.

Perhaps your other project, gremlin-script, can generate a valid script?

from gremlin-javascript.

dragma avatar dragma commented on June 9, 2024

In you last script (.then(count => {...}) cerebus is nothing.
try to add before somthing like cerebus = g.V().hasLabel('god')
BTW, I don't think this is an issue for the gremlin-javascript client, you might find more help there : https://groups.google.com/forum/#!forum/gremlin-users
Regards,
Flo

from gremlin-javascript.

batwicket avatar batwicket commented on June 9, 2024

thanks Dragma, but i'm not actually assuming that the promise resolutions are carrying state back to the client. I'm assuming a transaction on the server is carrying the variables, which would simplify matters. I did try plugging in g.V().hasLabel('god').. ideally it could be plugged directly into the .addE() expression, but no luck. I think perhaps this interface is designed more for query than mutation because there doesn't appear to be a way to pull, say, cerberus into a JS object then plug it in as a binding to a later expression. I don't really have time to dig into it at this point. Water finds a way...

from gremlin-javascript.

Related Issues (20)

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.