Hmm, that would be nice.
We can't have a rule on the User which return an Address (I think).
But we can have a rule on the User class which return users which have
an active address (which is not what you want).
Maybe we could support it with something like this:
class User
has_n :addresses
rule(:active, :addresses) { |address| address.active? }
end
User.first.addresses.active #=> only active addresses
Will do some thinking ...
Cheers
Andreas
> --
> You received this message because you are subscribed to the Google Groups
> "neo4jrb" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/neo4jrb/-/d8-4d6j7j9UJ.
> To post to this group, send email to neo...@googlegroups.com.
> To unsubscribe from this group, send email to
> neo4jrb+u...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/neo4jrb?hl=en.
HiHmm, that would be nice.
We can't have a rule on the User which return an Address (I think).
But we can have a rule on the User class which return users which have
an active address (which is not what you want).Maybe we could support it with something like this:
class User
has_n :addresses
rule(:active, :addresses) { |address| address.active? }
endUser.first.addresses.active #=> only active addresses
Will do some thinking ...
Cheers
Andreas
User.first.addresses does already return a Traversal.
If the User and Address class were declared like this:
class Address < Neo4j::Rails::Model
rule(:active) { self[:active] == true}
end
class User < Neo4j::Rails::Model
has_n(:addresses).to(Address)
end
Then it would possible to (automatically) add the method "active" on
the Traversal returned by User.first.addresses which will check if the
Address nodes has an incoming relationship '_active' to the class node
(rule node).
Another alternative is top allow combining Rules/Travesal and Cypher queries.
Example:
User.all.addesses.query{|address| address.city == 'malmoe'}
Just some quick thoughts ...
Cheers
Andreas
> --
> You received this message because you are subscribed to the Google Groups
> "neo4jrb" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/neo4jrb/-/oQTlZJw16JAJ.
HiUser.first.addresses does already return a Traversal.
If the User and Address class were declared like this:
class Address < Neo4j::Rails::Model
rule(:active) { self[:active] == true}
end
class User < Neo4j::Rails::Model
has_n(:addresses).to(Address)
end
Then it would possible to (automatically) add the method "active" on
the Traversal returned by User.first.addresses which will check if the
Address nodes has an incoming relationship '_active' to the class node
(rule node).
Another alternative is top allow combining Rules/Travesal and Cypher queries.
Example:
User.all.addesses.query{|address| address.city == 'malmoe'}
Just some quick thoughts ...Cheers
Andreas
I've now started to look at this, it's probably not that hard to
implement (or at least some of it)
I've created a new issue https://github.com/andreasronge/neo4j/issues/181
Cheers
Andreas
>> > neo4jrb+u...@googlegroups.com.
>> > For more options, visit this group at
>> > http://groups.google.com/group/neo4jrb?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups
> "neo4jrb" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/neo4jrb/-/ifvHCW3pXbMJ.
>
> To post to this group, send email to neo...@googlegroups.com.
> To unsubscribe from this group, send email to
> neo4jrb+u...@googlegroups.com.
kind regards,
Cyprian
On 16 kwi 2012, at 12:30, Andreas Ronge wrote:
> Hi
>
> I've now started to look at this, it's probably not that hard to
> implement (or at least some of it)
> I've created a new issue https://github.com/andreasronge/neo4j/issues/181
>
> Cheers
> Andreas
>
I'm making good progress on combining cypher, the traversal api and rules.
Check these RSpecs -
https://github.com/andreasronge/neo4j-wrapper/blob/master/spec/neo4j/rule/rule_cypher_integration_spec.rb
My favorite RSpec is this: "Give me all rooms in a dungeon where there
are dangerous monsters"
dungeon.monsters.dangerous { |m| rooms = m.incoming(Room.monsters); rooms }
This will create a cypher query for that (append a #to_s and you get
the cypher query as a String)
For simpler queries a hash value is supported, for example give me all
monsters with a weapon 'sword'
Monster.all(:weapon => 'sword')
Dangerous monsters are defined by a rule:
class Monster
include Neo4j::NodeMixin
property :age
rule :all
rule(:dangerous) { |m| m[:strength] > 15 }
end
Next - fix so this works from Neo4j::Rails::Model as well.
Btw, I removed the Neo4j::NodeIndex and merged into Neo4j::Node, same
with Neo4j::RelationshipIndex
Cheers
Andreas