4D v19

entitySelection.extract( )

Home

 
4D v19
entitySelection.extract( )

entitySelection.extract( )  


 

The entitySelection.extract( ) method returns a collection containing propertyPath values extracted from the entity selection. 

propertyPath can refer to:

  • a scalar dataclass attribute,
  • related entity,
  • related entities.

If propertyPath is invalid, an empty collection is returned.

This method accepts two syntaxes.

With this syntax, entitySelection.extract( ) populates the returned collection with the propertyPath values of the entity selection.

By default, entities for which propertyPath is null or undefined are ignored in the resulting collection. You can pass the ck keep null constant in the option parameter to include these values as null elements in the returned collection.

  • Dataclass attributes with dataClassAttribute.kind = "relatedEntity" are extracted as a collection of entities (duplications are kept).
  • Dataclass attributes with dataClassAttribute.kind = "relatedEntities" are extracted as a collection of entity selections.

With this syntax, entitySelection.extract( ) populates the returned collection with the propertyPath properties. Each element of the returned collection is an object with targetPath properties filled with the corresponding propertyPath properties. Null values are kept (option parameter is ignored with this syntax). 

If several propertyPath are given, a targetPath must be given for each. Only valid pairs [propertyPathtargetPath] are extracted.

 

Note: Entities of a collection of entities accessed by [ ] are not reloaded from the database.

Example  

Given the following table and relation:

 C_COLLECTION($firstnames;$addresses;$mailing;$teachers)
 C_OBJECT($status)
  //
  //
  //$firstnames is a collection of Strings
 $firstnames:=ds.Teachers.all().extract("firstname")
  //
  //$addresses is a collection of entities related to dataclass Address
  //Null values for address are extracted
 $addresses:=ds.Teachers.all().extract("address";ck keep null)
  //
  //
  //$mailing is a collection of objects with properties "who" and "to"
  //"who" property content is String type 
  //"to" property content is entity type (Address dataclass)
 $mailing:=ds.Teachers.all().extract("lastname";"who";"address";"to")
  //
  //
  //$mailing is a collection of objects with properties "who" and "city"
  //"who" property content is String type 
  //"city" property content is String type 
 $mailing:=ds.Teachers.all().extract("lastname";"who";"address.city";"city")
  //
  //$teachers is a collection of objects with properties "where" and "who"
  //"where" property content is String
  //"who" property content is an entity selection (Teachers dataclass)
 $teachers:=ds.Address.all().extract("city";"where";"teachers";"who")
  //
  //$teachers is a collection of entity selections
 $teachers:=ds.Address.all().extract("teachers")



See also 

collection.extract( )

 
PROPERTIES 

Product: 4D
Theme: ORDA - EntitySelection

 
PAGE CONTENTS 
 
HISTORY 

 
ARTICLE USAGE

4D Language Reference ( 4D v19)
4D Language Reference ( 4D v19.1)