README.md in redgraph-0.1.3 vs README.md in redgraph-0.1.4

- old
+ new

@@ -43,10 +43,20 @@ edge = Redgraph::Edge.new(src: actor, dest: film, type: 'ACTOR_IN', properties: {role: "Tony Montana"}) => #<Redgraph::Edge:0x00007f8d5f9ae3d8 @dest=#<Redgraph::Node:0x00007f8d5f85ccc8 @id=1, @label="film", @properties={:name=>"Scarface"}>, @dest_id=1, @properties={:role=>"Tony Montana"}, @src=#<Redgraph::Node:0x00007f8d5f95cf88 @id=0, @label="actor", @properties={:name=>"Al Pacino"}>, @src_id=0, @type="ACTOR_IN"> @graph.add_edge(edge) => #<Redgraph::Edge:0x00007f8d5f9ae3d8 @dest=#<Redgraph::Node:0x00007f8d5f85ccc8 @id=1, @label="film", @properties={:name=>"Scarface"}>, @dest_id=1, @id=0, @properties={:role=>"Tony Montana"}, @src=#<Redgraph::Node:0x00007f8d5f95cf88 @id=0, @label="actor", @properties={:name=>"Al Pacino"}>, @src_id=0, @type="ACTOR_IN"> +You can merge nodes - the node will be created only if there isn't another with the same label and properties: + + graph.merge_node(film) + => #<Redgraph::Node:0x00007f8d5f85ccc8 @id=1, @label="film", @properties={:name=>"Scarface"}> + +Same with edges: + + @graph.merge_edge(edge) + => #<Redgraph::Edge:0x00007f8d5f9ae3d8 @dest=#<Redgraph::Node:0x00007f8d5f85ccc8 @id=1, @label="film", @properties={:name=>"Scarface"}>, @dest_id=1, @id=0, @properties={:role=>"Tony Montana"}, @src=#<Redgraph::Node:0x00007f8d5f95cf88 @id=0, @label="actor", @properties={:name=>"Al Pacino"}>, @src_id=0, @type="ACTOR_IN"> + Find a node by id: @graph.find_node_by_id(1) => #<Redgraph::Node:0x00007f8d5c2c6e88 @id=1, @label="film", @properties={"name"=>"Scarface"}> @@ -69,14 +79,31 @@ Getting edges: @graph.edges @graph.edges(src: actor, dest: film) @graph.edges(kind: 'FRIEND_OF', limit: 10, skip: 20) + @graph.count_edges Running custom queries @graph.query("MATCH (src)-[edge:FRIEND_OF]->(dest) RETURN src, edge") +### NodeModel + +You can use the `NodeModel` mixin for a limited ActiveRecord-like interface: + + class Actor + include Redgraph::NodeModel + self.graph = Redgraph::Graph.new("movies", url: $REDIS_URL) + attribute :name + end + +And this will give you stuff such as + + Actor.count + john = Actor.new(name: "John Travolta") + john.add_to_graph # Will add the node to the graph + john.add_relation(type: "ACTED_IN", node: film, properties: {role: "Tony Manero"}) ## Development After checking out the repo, run `bin/setup` to install dependencies. Then, run