Why not something as simple as:

for each(var role in roles) {
    if(role == desiredRole)
        return true;
}
return false;

________________________________________
From: user-boun...@lists.neo4j.org [user-boun...@lists.neo4j.org] On Behalf Of 
Ville Mattila [vi...@mattila.fi]
Sent: Saturday, April 02, 2011 2:47 AM
To: user@lists.neo4j.org
Subject: [Neo4j] Looking for value from array-typed relationship property in 
traversal return filters (REST API)

Hi there,

I am getting pretty excited with the power of return evaluators in
traversing framework. However, since I am using the REST API, there
are certainly some restrictions.

I should build a return filter to return nodes with an incoming
relationship containing a certain value in one of its array-typed
properties. So far I have managed to build following query:

"return filter" : {
    "language" : "javascript",
    "body" : "if (position.length() > 0) {
                        var r = position.lastRelationship();
                        if (r.hasProperty('roles')) {
                            var roles = r.getProperty('roles');
                            // Something must be done here and end up
with true or false...
                        } else {
                            false;
                        }
                    } else {
                        false;
                    }"
}

An example of the relationship data is here:
"data" : {
 "roles" : ["super","admin","user"]
}

There is a comment "// Something must be done here...." in the
evaluator where I haven't been able to figure out anything to. How
could I test if roles variable has a certain value in it? I tried
different functions, but no luck yet.

Best regards,
Ville
_______________________________________________
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user
_______________________________________________
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user

Reply via email to