Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed GraphOfTheGods example #8

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 56 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,62 @@ var g = gremlin.wrap(graph);

g.V('name', 'saturn').next(function (err, saturn) {
g.start(saturn).in('father').in('father').next(function (err, grandchild) {
var name = grandchild.getPropertySync('name');
console.log(name);
grandchild.getProperty('name', function(err, name) {
console.log(name);
});
});
});
```

## The Graph of the Gods

These examples will attempt to mimic [Getting Started](https://github.com/thinkaurelius/titan/wiki/Getting-Started) from the Titan wiki using the graph visualized below.

![The Graph of the Gods](https://raw.githubusercontent.com/wiki/thinkaurelius/titan/images/graph-of-the-gods-2.png)

Error handling is omitted to keep the code readable.

>> gremlin> saturn = g.V('name','saturn').next()

```javascript
> g.V('name', 'saturn').next(function (err, vertex) {
console.log(vertex.toJSON());
});

{ id: '4' }
```


>> gremlin> saturn.map()

```javascript
> g.V('name', 'saturn').map().next(function (err, properties) {
console.log(properties);
});

{ name: 'saturn', age: 10000, type: 'titan' }
```


>> gremlin> saturn.in('father').in('father').name

```javascript
> g.V('name', 'saturn').in('father').in('father').next(function(err, vertex) {
vertex.getProperty('name', function(err, value) {
console.log(value);
});
});

hercules
```


>> gremlin> g.E.has('place',WITHIN,Geoshape.circle(37.97,23.72,50))

```javascript
> g.E().has('place', g.Geo.WITHIN, g.Geoshape.circleSync(37.97,23.72,50)).next(function(err, val) {
console.log(val.toJSON());
});

{ id: '6J-o-2i' }
```