.ref
Specifies and Object Reference
When a type references another type, it is not possible to directly query that object. The .ref
operator enables support for such an operation. It is similar to a JOIN operation in SQL. This is used to reference other types which have their own id
field and are first-class database objects.
Example: User and Profile
Given the following example of a User and a Profile:
The User object has fields such as name, and ID.
{
"id" : "abcd",
"name" : "earl1",
"email" : "[email protected]"
}
{
"id" : "defg",
"displayName" : "Earl 1",
"user" : {
"id" : "abcd",
"name" : "earl1",
"email" : "[email protected]"
}
"application" : {
"id" : "hijk",
"name" : "EXAMPLE"
}
}
It would, at a glance, make sense to attempt to query a Profile this way:
user.id:abcd
However, as User is a reference that will return no results. Therefore it is necessary to use the reference operator to perform the query:
.ref.user:abcd
This tells the query engine to execute the following:
Identify the client is requesting a reference to another object.
Identify the reference as the
user
field.Find a user with
id = "abcd"
Find all Profiles matching that user.
Last updated