-
Notifications
You must be signed in to change notification settings - Fork 5
Model CRUD
Hartmut Bischoff edited this page Mar 4, 2021
·
3 revisions
Public API for ActiveOrient::Base-Model Objects
#ORD Points to the OrientDB-Instance
ORD.create_class {class_name [, class_name , ...]} # String or Symbol ## returns allocated class
Klass.create_class {class_name [, class_name}, ...]} ## creates inherited classes
# special cases
V.create_class class_names # creates vertex classes
E.create_class class_names # creates edge classes V.create_class :t
t = T.create property: value , (...) # creates a document, attributes go into the Hash
t.update property: value # updates the document,
# or
t.{property} = {value}
t.save V.create_class :t
T.update set:{ attributes }, where: { condition }
T.upsert set:{ attributes }, where: { condition } # create a document, if where cause reveals no match V.create_class :t
# a single document
t = T.create attr: 'value'
t.delete
# several documents
T.delete where: {attr: 'value'} || T.delete where: 'a valid condition'
# any document of database class
T.delete all: truenote: if a vertex is deleted, all connected edges are removed, too
In ruby, a variable is reset by assignment with nil. If some database property should be erased, its set to NULL.
> T.update set: { some_property : nil }
> T.where some_property: [nil]
> T.count where: { some_property: [nil] }If a query is fired, the database is asked whether a property is NULL. This has to be coded via an Array containing nil.
Overview
Data Management
- Joining Tables, embedded Lists
- Links and Link Lists
- Relations
- Bidirectional Connections
- Working with Hashes
Public API
- Database
- Model CRUD
Misc