ex_orient v1.4.0 ExOrient.Functions

DSL for http://orientdb.com/docs/last/SQL-Functions.html

An attempt to move as much of the query language out of strings as possible.

Usage examples:

  > import ExOrient.DB
  > import ExOrient.Functions
  > select(out("works_for") |> expand(), from: Person) |> exec()
  > select(out("owns") |> expand(), from: Person) |> exec()
  > select(count("*"), from: Person) |> exec()

Important note: Some function names collide with Elixir syntax. These functions have o_ prepended onto their names. For example, o_in instead of in.

Summary

Functions

Functions

avg(field)

http://orientdb.com/docs/last/SQL-Functions.html#avg

> DB.select(avg(:salary), from: Person)
both()

http://orientdb.com/docs/last/SQL-Functions.html#both

> DB.select(both(Following), from: Person)
both(str)
both_e()

http://orientdb.com/docs/last/SQL-Functions.html#bothe

> DB.select(both_e(), from: Person)
both_e(str)
coalesce(field)

http://orientdb.com/docs/last/SQL-Functions.html#coalesce

> DB.select(coalesce(:amount), from: Person)
count(field)

http://orientdb.com/docs/last/SQL-Functions.html#count

> DB.select(count("*"), from: Person)
date(d)
date(d, f)
date(d, f, t)

http://orientdb.com/docs/last/SQL-Functions.html#date

> DB.select(date("03-08-2016", "MM-dd-yyyy", "UTC"), from: Person)
difference(field)

http://orientdb.com/docs/last/SQL-Functions.html#difference

> DB.select(difference(:friends), from: Person)
dijkstra(source, dest, field)

http://orientdb.com/docs/last/SQL-Functions.html#dijkstra

> DB.select(dijkstra("#11:0", "#11:27"), from: Person)
dijkstra(source, dest, field, dir)
distance(x_field, y_field, x, y)

http://orientdb.com/docs/last/SQL-Functions.html#distance

> DB.select(distance(:x, :y, 52.02342, 13.32142), from: Person)
distinct(field)

http://orientdb.com/docs/last/SQL-Functions.html#distinct

> DB.select(distinct(:surname), from: Person)
eval(expr)

http://orientdb.com/docs/last/SQL-Functions.html#eval

> DB.select(eval("1 + 2"), from: Person)
expand(str)

http://orientdb.com/docs/last/SQL-Functions.html#expand

> DB.select(expand(out(Following)), from: Person)
first(field)

http://orientdb.com/docs/last/SQL-Functions.html#first

> DB.select(first(:addresses), from: Person)
format(str, fields)

http://orientdb.com/docs/last/SQL-Functions.html#format

> DB.select(format("Mr. %s", [:surname]), from: Person)
in_e()

http://orientdb.com/docs/last/SQL-Functions.html#ine

> DB.select(in_e(), from: Person)
in_e(str)
in_v()

http://orientdb.com/docs/last/SQL-Functions.html#inv

> DB.select(in_v(), from: Person)
intersect(field)

http://orientdb.com/docs/last/SQL-Functions.html#intersect

> DB.select(intersect(:friends), from: Person)
last(field)

http://orientdb.com/docs/last/SQL-Functions.html#last

> DB.select(last(:addresses), from: Person)
list(field)

http://orientdb.com/docs/last/SQL-Functions.html#list

> DB.select(list("roles.name"), from: Person)
map(key, value)

http://orientdb.com/docs/last/SQL-Functions.html#map

> DB.select(map("name", "roles.name"), from: Person)
median(field)

http://orientdb.com/docs/last/SQL-Functions.html#median

> DB.select(mode(:median), from: Person)
mode(field)

http://orientdb.com/docs/last/SQL-Functions.html#mode

> DB.select(mode(:salary), from: Person)
o_abs(field)

http://orientdb.com/docs/last/SQL-Functions.html#abs

> DB.select(o_abs(:net_worth), from: Person)
o_if(expr, if_true, if_false)

http://orientdb.com/docs/last/SQL-Functions.html#if

> DB.select(o_if("true", "Do if true", "Do if false"), from: Person)
o_in()

http://orientdb.com/docs/last/SQL-Functions.html#in

> DB.select(o_in(Following), from: Person)
o_in(str)
o_max(field)

http://orientdb.com/docs/last/SQL-Functions.html#max

> DB.select(o_max(:salary), from: Person)
o_min(field)

http://orientdb.com/docs/last/SQL-Functions.html#min

> DB.select(o_min(:salary), from: Person)
out()

http://orientdb.com/docs/last/SQL-Functions.html#out

> DB.select(out(Following), from: Person)
out(str)
out_e()

http://orientdb.com/docs/last/SQL-Functions.html#oute

> DB.select(out_e(), from: Person)
out_e(str)
out_v()

http://orientdb.com/docs/last/SQL-Functions.html#outv

> DB.select(out_v(), from: Person)
percentile(field, p)

http://orientdb.com/docs/last/SQL-Functions.html#percentile

> DB.select(percentile(:salary, 95), from: Person)
set(field)

http://orientdb.com/docs/last/SQL-Functions.html#set

> DB.select(set("roles.name"), from: Person)
shortest_path(source, dest)

http://orientdb.com/docs/last/SQL-Functions.html#shortestpath

> DB.select(shortest_path("#11:0", "#11:27"), from: Person)
shortest_path(source, dest, dir)
shortest_path(source, dest, dir, class)
shortest_path(source, dest, dir, class, opts)
stddev(field)

http://orientdb.com/docs/last/SQL-Functions.html#stddev

> DB.select(stddev(:salary), from: Person)
sum(field)

http://orientdb.com/docs/last/SQL-Functions.html#sum

> DB.select(sum(:salary), from: Person)
symmetric_difference(field)

http://orientdb.com/docs/last/SQL-Functions.html#symmetricdifference

> DB.select(symmetric_difference(:friends), from: Person)
sysdate(f)
sysdate(f, t)

http://orientdb.com/docs/last/SQL-Functions.html#sysdate

> DB.select(sysdate("MM-dd-yyyy", "UTC"), from: Person)
traversed_edge(index)
traversed_edge(index, items)

http://orientdb.com/docs/last/SQL-Functions.html#traversededge

> DB.select(traversed_edge(-1), from: "TRAVERSE out() FROM #12:12")
traversed_element(index)
traversed_element(index, items)

http://orientdb.com/docs/last/SQL-Functions.html#traversedelement

> DB.select(traversed_element(-1), from: "TRAVERSE out() FROM #12:12")
traversed_vertex(index)
traversed_vertex(index, items)

http://orientdb.com/docs/last/SQL-Functions.html#traversedvertex

> DB.select(traversed_vertex(-1), from: "TRAVERSE out() FROM #12:12")
unionall(field)

http://orientdb.com/docs/last/SQL-Functions.html#unionall

> DB.select(unionall(:friends), from: Person)
uuid()

http://orientdb.com/docs/last/SQL-Functions.html#uuid

> DB.select(uuid(), from: Person)
variance(field)

http://orientdb.com/docs/last/SQL-Functions.html#variance

> DB.select(variance(:salary), from: Person)