Skip to content
Verified

Datasource

The shared binding shape that tells a program or a component where its data comes from and how to filter it.

A datasource is progDataSource, the object that says where a program's or a component's data comes from: a table, an inline array, raw JSON or CSV, or a URL, plus how to filter it, sort it and whether to keep it live. It is not something you create on its own in today's Studio, it is a section every Get Data, Set Data and data-aware Component carries, and all three read and write that section through the exact same shape and the exact same runtime resolver.

progDataSource

runAt on a datasource

A datasource resolves "" (inherit from its parent program), client (in the browser) or server (through the runtime's datasource_create service, keeping privileged queries off the client). The runtime overrides the stored value to client unconditionally in two cases: inside a Globals program, and when the session is running in app_computing_mode: "main".

Two shapes, same object

Single record by key (a form):

json
{
  "dataSourceType": "table", "dataSourceFilterModelType": "index",
  "dataSourceTableId": "392_tbl_…", "dataSourceIndexId": "<index-uuid>",
  "dataSourceIndexesObj": { "<index-uuid>": { "ORD_Id": { "from": "@order_id_in", "to": "@order_id_in", "key": "ORD_Id" } } }
}

Filtered list (a grid):

json
{
  "dataSourceType": "table", "dataSourceFilterModelType": "query",
  "dataSourceTableId": "392_tbl_…",
  "filterModelMongoFx": "({ ORD_Status: { $eq: @status_v } })",
  "dataSourceRealtime": true
}

Worked example

Pick the mode

Looking up one record by its key: index mode plus dataSourceIndexId. Filtering a list by a condition: query mode plus filterModelMongoFx.

Point it at a table

dataSourceTableId is the target Table's _id, never its name.

Turn on realtime where it matters

dataSourceRealtime: true keeps a bound grid in sync as rows change underneath it, on the native database driver only.

xml
<datasource lang="json5">
{
  type: "table",
  table: "student_profiles_table",
  filter: {
    mode: "query",
    queryField: "@campus_query_v"
  },
  output: "student_entries_v",
  direction: "asc",
  realtime: true,
  limit: 25
}
</datasource>

The .xu <datasource> block is the same information as progDataSource, in the shorthand xuda-cli compiles down to the Studio JSON shape.

json
"progDataSource": {
  "dataSourceType": "table",
  "dataSourceTableId": "5b1_tbl_a953848a71c5",
  "dataSourceFilterModelType": "index",
  "dataSourceIndexId": "a1b2c3d4-e5f6-4a7b-8c9d-0e1f2a3b4c5d",
  "dataSourceSort": "STU_Full_Name",
  "dataSourceRealtime": true
}