datasource

Modified on Wed, 22 Jul at 11:55 AM

datasource

TABLE OF CONTENTS

Fetch an entry from a data source

Definition

object datasource(string $dataSourceName, string $column, string $lookFor)

Gets the first object from $dataSourceName whose value of $column is equal to $lookFor.

Parameters

string $dataSourceName

Name of the data source to use.

string $column

Name of the column to search.

string $lookFor

The string value to look for in $column.

Returns

object

The first object in $dataSourceName whose value of $column in equal to $lookFor.

Examples

Example data source in table view.

Example data source in table view.

ExampleDataSourceJSONView
[
  {"id" : 0, "name" : "Julia", "age" : 30},
  {"id" : 1, "name" : "Alexander", "age" : 57}, 
  {"id" : 2, "name" : "Pete", "age" : 71}, 
  {"id" : 3, "name" : "Selma", "age" : 42}
]
Transformation
{
  julia: datasource('ExampleDataSource', 'name', 'Julia'),
  alexanderAge: datasource('ExampleDataSource', 'name', 'Alexander').age,
  alex: datasource('ExampleDataSource', 'name', 'Alex'),
  nameOf30YearOld: datasource('ExampleDataSource', 'age', '30').name,
  number57YearOld: datasource('ExampleDataSource', 'id', `57`)
}
Result
{
  "julia": {"id": 0, "name": "Julia", "age": "30"},
  "alexanderAge": 57,
  "alex": null,
  "nameOf30YearOld": "Julia",
  "number57YearOld": null
}

See also

  • datasource_many, a similar function that returns an array of all objects that match a certain value.

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article