Class: Neo4j::Label
- Inherits:
-
Object
- Object
- Neo4j::Label
- Extended by:
- Core::CypherTranslator
- Defined in:
- lib/neo4j/label.rb
Overview
A label is a named graph construct that is used to group nodes. See Neo4j::Node how to create and delete nodes
Direct Known Subclasses
Defined Under Namespace
Classes: InvalidQueryError
Constant Summary
Constants included from Core::CypherTranslator
Core::CypherTranslator::EMPTY_PROPS, Core::CypherTranslator::SANITIZE_ESCAPED_REGEXP
Class Method Summary (collapse)
-
+ (Object) create(name, session = Neo4j::Session.current)
Returns a label of given name that can be used to specifying constraints.
-
+ (Enumerable<Neo4j::Node>) find_all_nodes(label_name, session = Neo4j::Session.current)
All nodes having given label.
-
+ (Enumerable<Neo4j::Node>) find_nodes(label_name, key, value, session = Neo4j::Session.current)
All nodes having given label and properties.
Instance Method Summary (collapse)
-
- (Object) create_constraint(property, constraints, session = Neo4j::Session.current)
Creates a neo4j constraint on a property See docs.neo4j.org/chunked/stable/query-constraints.html.
- - (Object) create_index(*properties) abstract
-
- (Object) drop_constraint(property, constraint, session = Neo4j::Session.current)
Drops a neo4j constraint on a property See docs.neo4j.org/chunked/stable/query-constraints.html.
- - (Object) drop_index(*properties) abstract
-
- (Object) indexes
abstract
List indices for a label.
- - (Object) name abstract
Methods included from Core::CypherTranslator
create_escape_value, cypher_prop_list, cypher_string, escape_quotes, escape_value, label_string, prop_identifier, sanitize_escape_sequences, sanitized_column_names, translate_response
Class Method Details
+ (Object) create(name, session = Neo4j::Session.current)
Returns a label of given name that can be used to specifying constraints
67 68 69 |
# File 'lib/neo4j/label.rb', line 67 def create(name, session = Neo4j::Session.current) session.create_label(name) end |
+ (Enumerable<Neo4j::Node>) find_all_nodes(label_name, session = Neo4j::Session.current)
Returns all nodes having given label. Nodes can be wrapped in your own model ruby classes.
73 74 75 |
# File 'lib/neo4j/label.rb', line 73 def find_all_nodes(label_name, session = Neo4j::Session.current) session.find_all_nodes(label_name) end |
+ (Enumerable<Neo4j::Node>) find_nodes(label_name, key, value, session = Neo4j::Session.current)
Returns all nodes having given label and properties. Nodes can be wrapped in your own model ruby classes.
78 79 80 |
# File 'lib/neo4j/label.rb', line 78 def find_nodes(label_name, key, value, session = Neo4j::Session.current) session.find_nodes(label_name, key, value) end |
Instance Method Details
- (Object) create_constraint(property, constraints, session = Neo4j::Session.current)
Creates a neo4j constraint on a property See docs.neo4j.org/chunked/stable/query-constraints.html
35 36 37 38 39 40 41 42 43 |
# File 'lib/neo4j/label.rb', line 35 def create_constraint(property, constraints, session = Neo4j::Session.current) cypher = case constraints[:type] when :unique "CREATE CONSTRAINT ON (n:`#{name}`) ASSERT n.`#{property}` IS UNIQUE" else fail "Not supported constrain #{constraints.inspect} for property #{property} (expected :type => :unique)" end session._query_or_fail(cypher) end |
- (Object) create_index(*properties)
14 15 16 |
# File 'lib/neo4j/label.rb', line 14 def create_index(*properties) fail 'not implemented' end |
- (Object) drop_constraint(property, constraint, session = Neo4j::Session.current)
Drops a neo4j constraint on a property See docs.neo4j.org/chunked/stable/query-constraints.html
52 53 54 55 56 57 58 59 60 |
# File 'lib/neo4j/label.rb', line 52 def drop_constraint(property, constraint, session = Neo4j::Session.current) cypher = case constraint[:type] when :unique "DROP CONSTRAINT ON (n:`#{name}`) ASSERT n.`#{property}` IS UNIQUE" else fail "Not supported constrain #{constraint.inspect}" end session._query_or_fail(cypher) end |
- (Object) drop_index(*properties)
19 20 21 |
# File 'lib/neo4j/label.rb', line 19 def drop_index(*properties) fail 'not implemented' end |
- (Object) indexes
List indices for a label
25 26 27 |
# File 'lib/neo4j/label.rb', line 25 def indexes fail 'not implemented' end |
- (Object) name
9 10 11 |
# File 'lib/neo4j/label.rb', line 9 def name fail 'not implemented' end |