[Neo4j] Neo4j REST, python, prune evaluator trick/hack, and some more Q.

Mattias Persson mattias at neotechnology.com
Mon Jul 5 09:59:19 CEST 2010


2010/7/5 Sergey Nikitin <nikitinsm at gmail.com>

> Hi! I'v found that it is possible to alter database data inside
> traversal query like this:
>
> *PYTHON DICT*
> ...
>    "prune evaluator": {
>      "language": "javascript",
>      "body": """
>      if(position.node().getId().equals(12)){
>        position.node().setProperty('some_property','some_value');
>        false;
>      }else{
>        true;
>      }
>    },
>
> As I understand I can do the same with relationships but I didn't find
> how to get current Database Service instance (graphdb), can anybody
> tell me is it possible and has this trick right to life ?
>

Yep that's right, you can do modifying operations within a traversal in
neo4j. You can get the graph database instance from any node or relationship
via the method getGraphDatabase() (which sits on the PropertyContainer
interface).

>
>
> Also: if graphdb can bee accessed via javasctipt, is it means that I
> can do transactional operations via traversal query ?
>

on the REST server each request executes in its own transaction so that
managing transactions within a traversal in the REST request won't actually
start new transactions (since neo4j won't treats such transactions as true
nested transaction, see
http://wiki.neo4j.org/content/Transactions#Nested_transactions for more
information).

>
> Also too: It would bу nice to pass a custom JAVA code to REST with a
> custom output.
> for example: prepare some output on serverside with one query instead
> of quering dozens when I need to get relationships and some properties
> of a Nodes.
>

Yes, it's a good idea to expose your own a domain specific layer around the
REST API just like you said. There aren't any good documentation about how
to do that yet (that I'm aware of), but it will come I'm sure.


>
> --
> Best Regards, Nikitin Sergey
>
> ICQ 343833010
> phone:
> 8(926)013-55-66
>
> site: http://nikitinsm.ru
> email: nikitinsm at gmail.com
> skype: nikitinsm
> jabber: nikitinsm at gmail.com
> _______________________________________________
> Neo4j mailing list
> User at lists.neo4j.org
> https://lists.neo4j.org/mailman/listinfo/user
>



-- 
Mattias Persson, [mattias at neotechnology.com]
Hacker, Neo Technology
www.neotechnology.com


More information about the User mailing list