-
Notifications
You must be signed in to change notification settings - Fork 5
Initialisation
ActivdeOrient requires a running OrientDB-Server-instance
ORD = ActiveOrient::Init.connect database: <temp>,
user: <root>,
password: <root>,
server: <localhost>,
port: <2480>,
logger: <nil>
connects to the server, opens the database and gathers informations about server and database.
Base-Classes for Edges and Vertexes, E and V, are allocated.
The directive ActiveOrient::Model.keep_models_without_file
controls the preallocation process.
- If set to
false
, only database-classes with corresponding model-files are preallocated and assigned to theirActiveOrient::Model
class. - If set to
true
, any database class present is allocated to aActiveOrient::Model
class.
ActiveOrient::Model
-Methods are stored in (root)/lib/model
by default.
The location is overwritten by
ActiveOrient::Model.model_dir = project_root + '/model'
A typical setup using the ActiveOrient Gem:
#(after ActiveOrient::Init.connect)
project_root = File.expand_path('../..', __FILE__)
ActiveOrient::Model.model_dir = project_root + '/model'
ActiveOrient::OrientDB.new preallocate: true
Any new instance of ActiveOrient::OrientDB
(the REST-Client) initiates a fresh preallocation process. By explicitly setting ActiveOrient::Model.model_dir
, model files are required from the model
-directory of the application rather then the gem-root-dir.
ORD = ActiveOrient::Init.connect
project_root = File.expand_path('../..', __FILE__)
ActiveOrient::Model.model_dir = project_root + '/model'
ActiveOrient::Model.keep_models_without_file = false
# allocate classes from /model directory
ActiveOrient::OrientDB.new preallocate: true
module HC; end
ActiveOrient::Init.define_namespace { HC }
# allocate classes from /model/hc directory
ActiveOrient::OrientDB.new preallocate: true
# allocate any other classes and use methods defined in /model/tg
module TG; end
ActiveOrient::Init.define_namespace { TG }
ActiveOrient::Model.keep_models_without_file = true
ActiveOrient::OrientDB.new preallocate: true
Each ActiveOrient::Model
contains a reference to the ActiveOrient::OrientDB
-Instance. Further references are not required. Thus V.orientdb
could substitute the assignment of ORD
.
Due to limitations of the REST-protocoll, a query select from hc_basiswert where name like 'A%'
is not transmitted properly.
Instead, the function left
has to be used. The following code enables the call of HC::Basiswert.like {some string}
(/model/hc/basiswert.rb)
module HC
class Basiswert
class << self # class methods
def like p, order: 'asc'
p.chop! if ["%","*"].include?(p[-1])
p[0] = p[0].upcase
q = OrientSupport::OrientQuery.new where: { "name.left(#{p.length})" => p } ,
order: { :name => order }
query_database q
end
end
end # class
end # module
From the TimeGraph Gem.
Jahr
-Vertexes are connected to Monat
-Vertexes through MONTH_OF
-Edges. Anything is performed in the TG
-namespace. To access the connected Monat
-Vertex, the following helper was written. Its chainable.
( /model(tg/jahr.rb )
class TG::Jahr
def der_monat m
m >0 && m<13 ? out_tg_month_of[m].in : nil
end
end
Overview
Data Management
- Joining Tables, embedded Lists
- Links and Link Lists
- Relations
- Bidirectional Connections
- Working with Hashes
Public API
- Database
- Model CRUD
Misc