Simple select/from Examples
|
select x from Person x
returns a bag containing all the Person oids in the database select x.name from Person x returns a bag containing the name of every Person instance in the database select struct(name: x.name, age: x.age) from Person x returns a bag containing struct elements including the name and age of every Person instance in the database select list(x, x.name) from Person x where x.name ~ "h" returns a bag of list elements containing the oid and the name of every Person instances whose name matches the regular expression "h" select list(x, x.name) from Person x where x.name ~ "h" order by x.name same as previous example, but the result is a list ordered by the name of the persons select x from Person x where x.spouse.name = "john" or x.age < 10 returns a bag of Person instances whose spouse name is equal to "john" or the age is less than 10 select x from Person x order by x.name current implementation restriction: raises an error: x.name not found in projection |
Array and Collection based Query Examples
|
select x.name from Person x where x.name[0] = 'j'
returns all the Person instances whose name begins with a 'j' select x from Person x where x.other_addrs[0].street ~~ "par." returns all the Person instances whose first other_addrs street matches the regular expression "par." select x from Person x where x.other_addrs[?].street ~~ "par.." returns all the Person instances whose any other_addrs street matches the regular expression "par.." select x from Person x where x.other_addrs[1:3].street ~~ "par.." returns all the Person instances whose the first, second or third other_addrs street matches the regular expression "par.." select x from Person x where x.children[?].name = "johnny" returns all the persons whose one of its children is called "johnny" select x from Person x where x.cars[?].num < 100 or x.children[?].name = "mary" returns all the persons whose one of its cars has a number less than 100 or a child called "mary" select x from Person x where x.children[1].name = "johnny" although the children is a collection array, an error is raised. This is a current limitation of the implementation that will disapear soon |
Simple Implicit select Examples
|
select 1
returns 1 select Person returns a bag containing all Person instances in the database select Person.name returns a bag containing the name of every Person instances in the database select Person.name = "john" returns a bag containing the oids of every Person instances whose name is equal to "john" (select distinct Person.name = "john").age returns a set containing the age of every Person instances whose name is equal to "john" select Person.name = "john" or Person.age = 10 raises an error: use select/from/where clause select Person.name order by Person.name returns a list containing of the sorted names of all Person instances |
Query Schema Examples
|
select class.name = "Person"
returns a bag containing the class whose name is "Person" select class.type = "user" returns all the user classes select x from class x where x.name ~ "P" and x.type = "user" returns the user classes whose name matches the given regular expression select class.parent.name = "Person" returns a bag containing the sub-classes of the class Person |
EyeDB manual