class Sequel::Postgres::PropertyGraph::Generator::Element
Constants
- Data
Public Class Methods
new(name, opts=OPTS, &block)
click to toggle source
name specifies the name of the vertex or edge. It can be an SQL::AliasedExpression to use an alias. Options:
- :properties
-
Specifies fixed properties for the vertex or edge. If this is given, you cannot use the label method inside the block.
# File lib/sequel/adapters/shared/postgres.rb 284 def initialize(name, opts=OPTS, &block) 285 @name = name 286 @labels = [] 287 if opts.key?(:properties) 288 @labels << [nil, opts[:properties]].freeze 289 @labels.freeze 290 end 291 instance_exec(&block) if block 292 @labels.freeze 293 freeze 294 end
Public Instance Methods
data()
click to toggle source
# File lib/sequel/adapters/shared/postgres.rb 296 def data 297 Data.new(@name, @key, @labels).freeze 298 end
key(columns)
click to toggle source
Set the column(s) to use for the KEY clause, which are the columns that uniquely identify rows in the table:
key(:id) # KEY (id) key([:id1, :id2]) # KEY (id1, id2)
# File lib/sequel/adapters/shared/postgres.rb 308 def key(columns) 309 @key = Array(columns) 310 end
label(name, properties=:all)
click to toggle source
Add a label and properties for the label for this vertex/edge.
A vertex or edge can have multiple labels with separate properties, if it wasn’t created with fixed properties. The name argument specifies the label name. The properties argument specifies the properties:
- nil, :all
-
PROPERTIES ALL COLUMNS
- false, :none, []
-
NO PROPERTIES
Array-
Arrayof specific properties. Each element should be aSymbol,SQL::Identifier, orSQL::AliasedExpression.
label(:label_name) # LABEL label_name PROPERTIES ALL COLUMNS label(:label_name, []) # LABEL label_name NO PROPERTIES label(:label_name, [:c, Sequel[:b].as(:d)], Sequel[:e]) # LABEL label_name PROPERTIES (c, b AS d, e)
# File lib/sequel/adapters/shared/postgres.rb 330 def label(name, properties=:all) 331 if @labels.frozen? 332 raise Error, "cannot specify label for property graph vertex or edge with fixed properties" 333 end 334 @labels << [name, properties].freeze 335 nil 336 end