Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
type
Panel
bgColorwhite

COLLECT FROM [WHERE]


Use this function to create Creates a collection of entity or attribute instances (meeting certain criteria).


Syntax

Code Block
 COLLECT entity | attribute FROM collection [ WHERE ( expression ) ]


Inputs
  • entity or attribute - Entity or attribute to collect.
  • collection - A collection of entity instances.
  • expression - Boolean expression that represents the criterion the instance has to meet.


Return type

  • collection of entity instances
  • collection of attribute values
UI Text Box
Warning

A collections collection contains no duplicates. Intermediary COLLECT expressions can contain duplicates however, please see the note on collections and duplicates.


Examples

Suppose the following model. Entity Teacher has a multivalued relation with entity Child via the relation Teacher.teaches_Children.


Teacher instanceChild instanceChild.nameChild.hobbies
Teacher_1Child_1“Kim”“Reading”, “Dancing”
Teacher_1Child_2“Rick”“Tennis”, “Dancing”
Teacher_1Child_3“Bob”“Painting”, “Basketball”, “Reading”
Teacher_2Child_1“Kim”“Reading”, “Dancing”
Teacher_2Child_3“Bob”“Painting”, “Basketball”, “Reading”
Teacher_2Child_4“Mary”“Football”
ExpressionResultType
COLLECT Child.name FROM ALL Child[ “Kim”, “Rick”, “Bob”, “Mary” ]String (multivalued)
COLLECT Child FROM Teacher[Teacher_2].teaches_Children[ Child_1, Child_3, Child_4 ]Collection of Child instances
COLLECT Child.hobbies FROM Teacher[Teacher_1].teaches_Children[ “Reading”, “Dancing”, “Tennis”, “Painting”, “Basketball” ]String (multivalued)

COLLECT Child.name FROM ALL Child
WHERE ( Child.hobbies = "Reading" )

[ “Kim”, “Bob” ]String (multivalued)
COLLECT Child.hobbies FROM ALL Child
WHERE ( Child.name = "Mary" )
[ “Football” ]String (multivalued)



Back to top