Comments (5)
Hi richtera,
I've updated gRex to cater for multiple connections. It meant I had to change the API a little with regards to Transactions and how they are handled. If you would like to try it out it is in the 0.2.0 branch. The Readme in that branch reflects the changes. But here are the highlights.
To start a transaction you need to call begin. Below is an example of how to do it.
var trxn = g.begin();
var v1 = trxn.addVertex({'test':'NameA'});
var v2 = trxn.addVertex({'test':'NameB'});
trxn.addEdge(v1, v2, 'aLabel');
trxn.commit().then(function(result){
console.log(result);
}, function(err) {
console.error(err)
});
Some other things to note.
Transaction success no longer requires testing for success = true || false. Only successful values are returned to success callback. All errors are sent to error callbacks.
I totally removed get() from the API, as it was a redundant call.
I haven't pushed this branch to NPM as yet. I has some minor adjustments to make before doing that. But if you have the time it would be great if you could give this a try.
Thanks
Frank
from grex.
Much better, although I would really like even require('grex') to return a constructor accepting options so I can have multiple connections. I also noticed that when executing g.V('key', val) where val is a variable only works for numbers or expressions matching graph references or ids. I have val being a plain string and wrapping it with quote also does the wrong thing. I can work on a pull request for that if you'd like.
I was thinking of changing _parseArgs to look for single or double quote in the beginning of strings passed in and then output them into gremlin verbatim.
from grex.
Great. So you confirm that the Transactions work as you expect. With regard to the other issues.
I think the constructor approach is a good idea. I'll look at that for a future release.
The g.V('key', val) looks like a bug. Are you able to open another issue with this scenario. Maybe give an example of what you are trying to do.
And all pull requests are welcome and appreciated, so feel free to submit a pull request.
Thanks
Frank
from grex.
Yes transactions work well although tp:batch doesn't use json types whereas addVertix does. So adding a vertex using addVertex and then updating using updateVertex will modify all data to string format.
I temporarily added support to pass {verbatim:json} as any parameter. This allows you to use JSON.stringify() when you know the parameter is of a specific type.
I was thinking of adding typed stuff using "(list,(...))" "(map,(id=..." and so on as part of parameter parsing.
Thanks
Andy
On Jul 16, 2013, at 9:10 PM, Frank Panetta [email protected] wrote:
Great. So you confirm that the Transactions work as you expect. With regard to the other issues.
I think the constructor approach is a good idea. I'll look at that for a future release.
The g.V('key', val) looks like a bug. Are you able to open another issue with this scenario. Maybe give an example of what you are trying to do.And all pull requests are welcome and appreciated, so feel free to submit a pull request.
Thanks
Frank—
Reply to this email directly or view it on GitHub.
from grex.
OK Thanks. I'll close this off and publish to NPM the first chance I get.
Also I thought tp:batch did use json types. I should check out what's going on there.
The typing would be a good addition, but I would like to keep the syntax as close to gremlin as possible. We may need to flesh this out.
Thanks
Frank
from grex.
Related Issues (20)
- Array arguments not parsed properly HOT 4
- Boolean parameters are converted to strings HOT 2
- Cannot perform Elasticsearch queries HOT 1
- isFloat() returns true for some GUIDs HOT 1
- Limit on the size of script is around 8K HOT 5
- Flowrank using Grex HOT 6
- Except/Retain Pattern HOT 4
- how can I addVertex only if not exists and addEdge only if not exists using grex script in one query for execute HOT 4
- How can I do Bulk insert using grex with titan ( for huge amount of vertex and edges) HOT 1
- Support for removeVertex HOT 1
- Passing array argument results in java class cast exception
- *Question Really* How Do I Send Parameters Into server-side script HOT 5
- Add custom error types when handling errors
- Consider dynamically adding steps with Gremlin.getStepNames()
- Vertex returned server-side script can't be used in a transaction
- Titan 0.9 and Tinkerpop 3 HOT 3
- Replication HOT 1
- setProperty() example? HOT 1
- javax.script.ScriptException with Object argument HOT 2
- Erratic api behavior, am I missing something? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from grex.