Possessive notation

Learn how to access properties using a phrase-like form.

The possessive notation is another way to access properties in CQL that emphasizes natural language. It is complementary to the ownership notation and can be used interchangeably or in combination with it.

The syntax for the possessive notation consists of the keyword property followed by the property name, the keyword of, and the value or variable name.

Here is an example that accesses the interests property of the user variable:

property interests of user
Try in Playground

You can access nested properties by chaining multiple property accesses together.

property city of property address of user
Try in Playground

As mentioned earlier, you can combine the possessive notation with the ownership notation for an even more natural sentence:

property city of user's address
Try in Playground

You can optionally add the word the before the property name to make the sentence more readable depending on the context:

the property city of user's address is equal to 'New York'
Try in Playground

To combine the possessive notation with other technical notations, such as the bracket notation, you can use parentheses:

(property interests of user)[0]
Try in Playground

While the possessive notation can provide a more natural way to access properties in some scenarios, it may not always be the most suitable choice for all situations.

Consider using the possessive notation when:

  • The property name is a valid identifier and is known in advance.
  • The property is not deeply nested.
  • You prefer writing queries using a more natural language style.
  • You want to combine it with the ownership notation for a more natural sentence.