This is awesome. Yaaaahhh!!
foo
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'bundler/setup' | |
require 'dotenv' | |
Dotenv.load | |
require 'tinify' | |
require 'json' |
def trace_execution(levels = 4) | |
cyan = "\e[36m" | |
clear = "\e[0m" | |
green = "\e[32m" | |
indent = 0 | |
output = '' | |
trace = TracePoint.new(:call, :c_call, :return, :c_return) do |tp| | |
if [:return, :c_return].include?(tp.event) && indent.nonzero? |
File 1
Open question for the Neo4j.rb community:
ActiveNode models allow for query chaining like so:
object.foo.bar.baz
This is a powerful way to traverse entities which builds Cypher queries under the covers. It is also currently possible to name your variables for later use like so:
object.foo(:f).bar.baz(:b).pluck(:f, 'collect(b)')
This is a test gist
CREATE a;
MATCH a RETURN a;
Welcome to the sixth episode in a series of short screencasts about the Ruby neo4j gem. Previously we learned how to chain associations together to create queries which can hop across entities and use any part of the entire path to query records of interest. In this episode we dig deeper into the tools behind the magic. A familiarity with the Cypher query language is advised. See the show notes for a link to a Cypher tutorial.
As discussed previously, when we call associations we get a proxy object:
user.created_assets
There are two kinds of proxy objects: AssociationProxy
and QueryProxy
. The details aren't important for the moment, but behind the scenes both are causing a Query
object to be built. We can see this Query
object by calling the query method at any point:
user.created_assets.query
Welcome to the fifth episode in a series of short screencasts about the Ruby neo4j gem. In this episode we will discuss the ActiveRel module which allows us to define model classes for Neo4j relationships.
In previous episodes we've seen that it's possible to work with Neo4j relationships via ActiveNode associations. While associations provide a lot of power through the abstraction of relationships as ties between nodes, Neo4j often allows us to think about relationships as entities worthy of consideration by themselves. When we want a richer representation of a relationship it is useful to create a representative model with it's own structure and logic. In the neo4j
gem this is done via the ActiveRel
module.
Defining an ActiveRel module is only slightly more complicated than defining an ActiveNode module.
class Viewed
include Neo4j::ActiveRel
Welcome to the fourth episode in a series of short screencasts about the Ruby neo4j gem. In this episode we will discuss how to chain associations to create complex queries with the power of Neo4j and the ease of Ruby. You may want to be familiar with Neo4j's Cypher query language before watching this episode, but if you aren't everything should still be comprehensible.
In our asset portal application we have a User
model with a created_assets
association. This association represents assets which are found by traversing outgoing relationships of the type CREATED
:
class User
has_many :out, :created_assets, type: :CREATED, model_class: :Asset
end
Furthermore, on our Asset
model we have a simple categories
association which represents the categories for assets.