Path Expressions

The path expression operator -> (identical to .) is used to navigate from an object and read the right data one needs. This operator enables us to go inside complex objects, as well as to follow simple relationships. For instance, if p denotes a Person instance, p.spouse denotes the spouse attribute of this person.
The more complex expression p.spouse.address.street denotes the street in the address of spouse of the person p. This notation is very intuitive because it looks like the well known C, C++ and Java syntaxes.

The path expression operator may composed a left value, for instance:
p.spouse.name := "mary";
set the name of the spouse of the person p to mary.

This operator may be combined with the array deferencing operators, for instance:
p.spouse.name[2];
p.spouse.name[2] := 'A';
p.spouse.other_addrs[2].street[3] := 'C';
p.spouse.children[?];
p.spouse.children[?].name;
The path expression operator may be also used to navigate through struct atom, for instance: (struct(a : 1, b : "hello")).b returns "hello". Note that because of the precedence of operators, parenthesis are necessary around the literal struct construct.
Finally, the path operator may be applied to a collection; in this case a collection of the same type of this operand is returned. For instance:
(select Person).name returns a bag of string.
(select distinct Person).age returns a set of int.
Note that the path expression operator is used frequently in the query expressions as shown in a next section.
General Information
Operators .
  ->
Syntaxes expr . expr
  expr -> expr
Type binary
Operand Types first operand: oid or object, second operand: identifier
Result Type type of the attribute denoted by the second operand
Functions returns the attribute value denoted by second operand of the object denoted by the first operand
  The first operand must denote an EYEDB instance (object or literal) of an agregat including the attribute denoted by the second operand.
Note these two operators are identical

Expression Examples
expression result comments
p->name the value of attribute name in the object denoted by p p must denote an EYEDB instance (object or literal) of an agregat including the attribute name
first(select x Person x from x.lastname = "wayne")->lastname "wayne"  

EyeDB manual