Advanced Data Access

In addition to loading a single record or a list, you can also load "deep", which loads all the sub-types of a record - such as comments, an audit trail, or any other nested records you define.

To do this, you simply put "with deep" in the load statement:

var #task = load(&path with deep)
 

This will load the task, and all nested records underneath that. To access those, you just use the slash syntax to access them:

var #comments = #task/Comments
 

Often your records will contain links to other records. You can access fields in that linked record also using the slash syntax. For example if your task had a field called "Author" that linked to a user record, you could access the full name of that author like this:

log #task/Author/FullName
 

You may also want to load the author user into its own variable:

var #author = load(GetPath(#task/Author))
 

This will make #author contain the user record that was selected in the Author link.

 Another advanced feature of loading is called a descendents query. If you have a large database hierarchy, and have the same data type repeated in different parts of the database, you can load ALL records of that type at a specific location like this:

var #list = load(all &root/Task below &path)
 

This will load all records of the type "Task" below the current &path location. If you had subtasks, or tasks under other records, it will get them all in one place. If you want to retrieve ALL tasks across the whole database, simply put "below &root".

You can also put predicates in there, to get all tasks created by John for example:

var #list = load(all &root/Task[Author="John"] below &root)
 


Next Topic:
v4.2.0.956 (beta)
Up Since 2/29/2024 12:02:23 AM