DEV Community

Hartmut B.
Hartmut B.

Posted on • Edited on

Active Orient – Introduction & Overview

How about a (fast) open source database usable without any schema, query-able with sql-statements and able to perform sophisticated graph operations? Not to forget: Easily accessible via an intuitive ruby interface. The latter is ActiveOrient.

Prerequisites

git clone https://github.com/topofocus/active-orient.git
cd active-orient
bundle install; bundle update
Enter fullscreen mode Exit fullscreen mode

Now modify config/connect.yaml.
Test, development and production databases are created if they don't exist.

Then change to /bin and run

./active-orient-console -t
Enter fullscreen mode Exit fullscreen mode

Simple Start

Any database-class is recognized and allocated. Further, any class created in the process is usable immediately. The behavior of any Class can be customized in model-files, which are included upon the creation of a class.

The base-classes V)ertex and E)dge are always present. Its good practice, to inherent any user-class from the base-classes.

 # create a class
    V.create_class :m   # V is the base »vertex» class. M is the vertex-class created The corresponding database-class: »m«.
 # INFO->CREATE CLASS m EXTENDS 

 # create a record
    M.create name: 'Hugo', age: 46, interests: [ 'swimming', 'biking', 'reading' ]
 # INFO->CREATE VERTEX m CONTENT {"name":"Hugo","age":46,"interests":["swimming","biking","reading"]}
    # query the database
    hugo = M.where( name: 'Hugo' ).first
    hugo.to_human
    =>"<M[177:0]: age: 46, interests: [\"swimming\", \"biking\", \"reading\"], name : Hugo>" 
    # update the dataset
    hugo.update father: M.create( name: "Volker", age: 76 )  # we create an internal link
# INFO->CREATE VERTEX m CONTENT {"name":"Volker","age":76}
# INFO->update #177:0 set father = #178:0
    hugo.to_human
    => "<M[177:0]: age : 46, father : <M[178:0]: age : 76, name : Volker>, interests : [\"swimming\", \"biking\", \"reading\"], name : Hugo>"
    hugo.father.name    
    => volker
    # change array elements
    hugo.interests << "dancing"  # --> [ 'swimming', 'biking', 'reading', 'dancing' ]
#INFO->update #177:0  set interests = interests || ['dancing'] 

    M.remove hugo 
    M.delete_class  # removes the class from OrientDB and deletes the ruby-object-definition
Enter fullscreen mode Exit fullscreen mode

In this brief introduction, we created a Vertex-Class »M«. Then we created a document (record) with some properties. We queried the database using a syntax similar to ActiveRecord.
Then we created a self-refrencing link which we followed to access connected information.

At last – using the syntax of ruby-arrays – we added an entry to an embedded list. Anything without any configuration in schema-, model-files or whatsoever.

This ends Part 1 of the ActiveOrient Mini-Series.
The next part covers unidirectional links and joins, an introduction to sql-queries and their abstraction with Orientquery

ACI image

ACI.dev: Best Open-Source Composio Alternative (AI Agent Tooling)

100% open-source tool-use platform (backend, dev portal, integration library, SDK/MCP) that connects your AI agents to 600+ tools with multi-tenant auth, granular permissions, and access through direct function calling or a unified MCP server.

Star our GitHub!

Top comments (0)

AWS GenAI LIVE image

How is generative AI increasing efficiency?

Join AWS GenAI LIVE! to find out how gen AI is reshaping productivity, streamlining processes, and driving innovation.

Learn more