Giter Club home page Giter Club logo

active-orient's Introduction

ActiveOrient

Use OrientDB to persistently store Ruby-Objects and use database queries to manage even very large datasets.
OrientDB Version 3 is required, OrientDB 3.1 is supported


Status

  • Gem Version 0.80 pushed on Dec. 22, 2020

Quick Start

You need a ruby 2.6 / 2.7 Installation and a working OrientDB-Instance (Version 3.0.17 or above).

  • clone the project,
  • run bundle install ; bundle update,
  • update config/connect.yml,
  • create the documentation:
  sdoc . -w2 -x spec -x example

and point the browser to ~/active-orient/doc/index.htm

  • read the Wiki
  • and start an irb-session by calling
cd bin
./active-orient-console t)est   # or d)develpoment, p)roduction environment as defined in config/connect.ym

Philosophy

OrientDB is a Multi-Model-Database. It shares the concept of Inheritance with OO-Languages, like Ruby.

Upon initialization ActiveOrient reads the complete structure of the database, creates corresponding ruby-classes (including inheritance) and then loads user defined methods from the Model Directory. A separate schema definition is not neccesary.

ActiveOrient queries the OrientDB-Database, provides a cache to speed things up and provides handy methods to simplify the work with OrientDB. Like Active-Record it represents the "M" Part of the MCV-Design-Pattern. There is explicit Namespace support. Its philosophie resembles the Hanami Project.

CRUD

The CRUD-Process (create, read = query, update and remove) is performed as

    # create the class
    V.create_class :m   # V is the base »vertex» class. M is a vertex-class.
    # create a record
    M.create name: 'Hugo', age: 46, interests: [ 'swimming', 'biking', 'reading' ]
    # query the database
    hugo = M.where( name: 'Hugo' ).first
    # update the dataset
    hugo.update father: M.create( name: "Volker", age: 76 )  # we create an internal link
    hugo.father.name	# --> volker
    # change array elements
    hugo.interests << "dancing"  # --> [ 'swimming', 'biking', 'reading', 'dancing' ]
    M.remove hugo 
    M.delete_class	# removes the class from OrientDB and deletes the ruby-object-definition

Active Model interface

As for ActiveRecord-Tables, the Model-class itself provides methods to inspect and filter datasets form the database.

  M.all   
  M.first
  M.last
  M.where town: 'Berlin'
  M.like "name =  G*"

  M.count where: { town: 'Berlin' }

»count« gets the number of datasets fulfilling the search-criteria. Any parameter defining a valid SQL-Query in Orientdb can be provided to the »count«, »where«, »first« and »last«-method.

A »normal« Query is submitted via

  M.query.projection( projection-parameter)
	  .distinct( some parameters)
	  .where( where-parameter)
	  .order( sorting-parameters )
	  .group_by( one grouping-parameter )
	  (...)
	 .execute

To update several records, a class-method »update« is provided.

  M.update connected: false   	# add a property »connected» to each record
  M.update set:{ connected: true },  where: "symbol containsText 'S'" 

Graph-support:

  V.create_class :the_vertex
  E.create_class :the_edge
  vertex_1 = TheVertex.create  color: "blue"
  vertex_2 = TheVertex.create  flower: "rose"
  vertex_1.assign via: TheEdge, vertex: vertex_2, attributes: {:birthday => Date.today }

It connects the vertices and assigns the attributes to the edge.

To query a graph, SQL-like-Queries and Match-statements can be used (details in the wiki).

Other Documents

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.