# Data

Apps access and store data via *data sources*. Each app has access to some built-in data sources containing local variables and client information. You can also create your own data sources in order to create, read, update and delete objects in the database. Data sources are also used in [services](https://docs.appfarm.io/reference/services).

[Built-in data sources ](#built-in-data-sources)include [App variables](https://docs.appfarm.io/reference/apps/data/app-variables) for managing the state of your app, as well as others for accessing details of the [current user](#current-user) and [navigation state](#url-path).

Creating your [own data sources](https://docs.appfarm.io/reference/apps/data/data-sources) is how you expose the [object classes](https://docs.appfarm.io/reference/data-model/object-classes) you have defined in the [Global data model](https://docs.appfarm.io/reference/data-model) to an app. A data source is populated with [objects](https://docs.appfarm.io/reference/platform-concepts/objects) and you use dedicated action to nodes to interact with them.

## Data sources

Your own data sources are a key element to every app. A data source is a window into the database where you can create, read, update, and delete objects. You can also create [runtime data sources](https://docs.appfarm.io/reference/apps/data-sources#database-connected-and-runtime-only-data-sources) for working with data in a temporary state or [calendars](https://docs.appfarm.io/reference/apps/data/calendar-data-sources).

{% content-ref url="data/data-sources" %}
[data-sources](https://docs.appfarm.io/reference/apps/data/data-sources)
{% endcontent-ref %}

## Built-in data sources

Every app has a number of built-in data sources. Practically every app will use [App variables](#app-variables), but use of the others will depend on the specific functionality in your app.

### App variables

App variables contain both built-in and custom variables that are used to hold global app state.&#x20;

{% content-ref url="data/app-variables" %}
[app-variables](https://docs.appfarm.io/reference/apps/data/app-variables)
{% endcontent-ref %}

### Current user

**Current user** is a effectively a single-cardinality data source based on the User [object class](https://docs.appfarm.io/reference/data-model/object-classes). It contains the user object of the currently logged-in user. If you have configured [unauthenticated access](https://docs.appfarm.io/how-to/authentication-and-access-control/unauthenticated-access) and a user is not logged in, this data source will be empty.

### Current user roles

**Current user roles** contains a list of the [roles](https://docs.appfarm.io/reference/security/roles) in your solution as boolean properties. If an active user has been assigned a particular role, the property will be true. If they are not a member, the property will be false. This can be used for example, to restrict visibility to parts of the UI based on role.

### Resource files

**Resource files** contains a list of the static files available to an app. This contains all items uploaded to [Files](https://docs.appfarm.io/reference/resources/files).

### URL parameters

**URL parameters** stores the available query parameters in an app. URL parameters are variables that can be included in the apps URL, such as `search=appfarm`. You can create logic to check for parameters and run actions based on the values. A common use case is to create a deep link to specific object.

#### Example

{% tabs %}
{% tab title="Create deep links to an object" %}
You have a view that displays event details and you want to load that view and display an event according to the ID specified in a URL parameter when the app is loaded.

Create a URL parameter `eventID` with the **Data Type** set as a reference to an `Event` object class. Run an action using the [On App Load](https://docs.appfarm.io/reference/app-settings#event-handlers) event handler to check for the presence of a value in this parameter (an event ID). If there is a value, select that event in the `Events` data source and navigate to the event details page.

You can then share a link to a specific event, such as <https://thirty50.appfarm.app/events?eventID=63755d984575> and when a user clicks that link they will be taken directly to the details page for that event.

For more information about how to set this up, see [How to create deep links](https://docs.appfarm.io/how-to/enhance-your-app/deep-links).&#x20;
{% endtab %}
{% endtabs %}

{% hint style="info" %}
**Good to know**

The first URL parameter included in a URL must be preceded with a question mark (?).

If you have a URL with multiple URL parameters, each parameter is joined with an ampersand (&).

For example:`?eventID=63755d984575&showSimilarEvents=true`
{% endhint %}

<table><thead><tr><th width="177">Property</th><th>Description</th></tr></thead><tbody><tr><td><strong>Key</strong></td><td>The name of the parameter. The key must be unique among URL parameters and not contain any special characters.</td></tr><tr><td><strong>Data Type</strong></td><td>The type of data allowed to be stored in this parameter. See <a href="#data-types">data types</a>.</td></tr><tr><td><strong>Description</strong></td><td>A longer description of the URL parameter. For your own reference.</td></tr></tbody></table>

### URL path

**URL path** stores navigational state variables. It holds the end-users's currently active view and optionally the active subview if a [view container](https://docs.appfarm.io/library/ui-components/view-container) is in use.

For example, if an end-user has navigated to <https://thirty50.appfarm.app/events/my-events>, the value of `URL Path.View` would be `my-events`.

<table><thead><tr><th width="150.33333333333331">Property</th><th width="152">Data type</th><th>Description</th></tr></thead><tbody><tr><td><strong>View</strong></td><td>Enum (View)</td><td>The end-user's currently active <a href="ui/views">view</a>.</td></tr><tr><td><strong>Subview</strong></td><td>Enum (View)</td><td>The end-user's currently active subview, if a <a href="../../library/ui-components/view-container">view container</a> is in use.</td></tr></tbody></table>
