# Datastore

> Design, manage, and leverage your app's datastore in PandaSuite: structure, data binding, no-code actions (edit, sync, export), offline mode, and best practices.

https://docs.pandasuite.com/essentials/data/datastore/

**The Datastore brings together two often separate needs: storing your app’s local data (variables, progress, preferences) and managing content collections like a lightweight CMS.**

## How it works

### Role 1 — Local variable manager

The Datastore stores data specific to each user, directly on their device:

- **Scores & progress**: level reached, points accumulated, unlocked steps
- **Preferences**: chosen language, dark mode, text size
- **App state**: tutorial already seen, bookmarked items, pre-filled forms

This data survives app closure but stays local — each user has their own independent copy.

[Image: Datastore used as a local variable manager: a score property of type Number with a default value of 0]

### Role 2 — Lightweight CMS for your collections

The Datastore can also hold structured content that you manage from Studio and push to your users:

- **Product catalog**: regularly updated list of items
- **Dynamic pages**: editorial content without rebuilding the app
- **Configuration**: settings editable remotely

In this case, you edit the content in the Data Editor, then users retrieve updates via the **Fetch remote data** action.

[Image: Datastore used as a CMS: a museum audioguide collection with Name, Audio, Author, Image, Date, and Description columns]

> **Info: No server required**
>
> Everything works locally, even offline. One user's changes never affect
> others.

## Create your datastore

### Add the component

In the **Data source** panel, choose **Datastore**.
The component is added at the **Project** level so it's accessible everywhere.

[Image: Data source menu in PandaSuite Studio showing PandaSuite Datastore, Airtable, Xano, and Generic API options] You can add multiple Datastores within the same project to segment your uses (for example: app progress vs editorial content).

Click the arrow to open the **Data Editor** — a spreadsheet-style editor that opens in a window of PandaSuite Studio.

### Data Editor features

- **Grid view**: each column is a property, each row is an item — you see everything at once.
- **JSON view**: switch to a raw JSON view via the **{ }** button (top-right), with **Import** and **Export** options.
- **Filtering**: use the **Advanced filters** side panel to filter by content, type, or value. Filters change which rows are visible without changing their order.
- **Manual row order**: drag rows to reorder them. The Data Editor does not currently sort rows automatically by a column value.
- **Multi-select**: check multiple rows to duplicate or delete them in bulk via right-click.
- **Column management**: reorder, pin, or hide columns using the contextual menu (**...**) in each column header.
- **Undo / Redo**: undo or redo recent changes using the arrows in the top-right toolbar.

[Image: Datastore Advanced filters panel: the people collection filtered on Name contains “mi”, leaving 4 of 15 rows]

### Define the structure

[Image: Searchable data type menu opened from + New property in the Datastore: Array, Audio, Boolean, Collection, Color, Date, Image, and more]

1. Click **+ New property** (bottom-left of the grid).
2. Choose the **[data type](https://docs.pandasuite.com/essentials/data/data-types/)** from the searchable menu: Text, Number, Boolean, Collection, Image, Reference, Audio, Video, Date, Color, and more.
3. Rename and set the default value directly in the grid cell.

> **Tip: Choose Collection for records**
>
> For a property holding several records with the same fields, such as recipes,
> products, or articles, choose **Collection** rather than **Array**: a
> Collection gives each item an identifier and a reusable **Reference**. Use
> **Array** for simple ordered lists where index-based access is enough. More in
> [Array or Collection?](https://docs.pandasuite.com/essentials/data/data-types/#collection).

> **Success: Save & deploy**
>
> Each change requires you to click **Save** (disk icon, top-right of the Data
> Editor) and then **Deploy** to include it in your builds or remote preview.

## Manipulate data

All operations are triggered from the **Actions** panel — no code required.

### Create / Edit data (local)

This action edits data **only on the user's device**.
It's the most common action for handling scores, preferences, or app state.

> **Info: Important reminder**
>
> These edits stay on the device. They're not sent to PandaSuite servers or
> shared with other users.

In the **Actions** panel, select any trigger, then: **Interact with a data source → Datastore → Create/Update Data (Local)**. Select the target property and choose the function to apply:

| Function                  | Data type | Effect                                   |
| ------------------------- | --------- | ---------------------------------------- |
| **Set**                   | All       | Fully replaces the value                 |
| **Increment / Decrement** | Number    | Adds or subtracts a numeric value        |
| **Add**                   | Array     | Appends an item to the end of the list   |
| **Remove by value**       | Array     | Removes a specific item from the list    |
| **Remove by id**          | Array     | Removes an item by its unique identifier |
| **Delete**                | All       | Completely deletes the data              |

[Image: Create/Update Data (Local) action in PandaSuite Studio: targeting /score with the Increment function set to 1]

### Fetch remote data

This action retrieves updates to the model from Studio — especially useful for dynamic content.

Merge remote data with local data: yes or no

1. **No (without merge)**: completely replaces local data with data from PandaSuite Studio
   - ✅ Ideal for: product catalog, editorial content
   - ❌ Beware: overwrites local changes (scores, preferences)

2. **Yes (merge)**: intelligently combines local and remote data
   - ✅ Keeps user changes
   - ✅ Adds new items from Studio
   - ✅ Updates default values not modified locally

> **Example: Concrete example**
>
> You have a collection of game levels. The user unlocked levels 1 to 5.
> You add 3 new levels in Studio.
>
> - **Without merge**: the user loses their progress.
> - **With merge**: the user keeps their progress **and** gets the new levels.

#### When to sync?

| Moment                   | Why                              |
| ------------------------ | -------------------------------- |
| On app launch            | Retrieve the latest updates      |
| "Refresh" button         | Let the user trigger it manually |
| After regaining internet | If the app was used offline      |

### Export data (local)

The **Export Data** action creates a file with the data at the path you choose (the whole Datastore by default), in JSON (the default) or CSV. CSV only works for a list (an Array or a Collection): use JSON for other local data, such as scores or preferences. Useful for analytics, support, or letting users back up their progress.

> **Info: Local export only**
>
> The file is created and stored on the device. To send it to a server, you'll
> need to use [an external API](https://docs.pandasuite.com/essentials/components/http/).

## Delete your datastore

Go to the **Project** tab, select your datastore, and click the delete icon.

## When to use what?

The Datastore covers most app needs. For cases that go beyond local storage, combine it with an external service rather than replacing it entirely.

| Need                                            | Solution                                                                                                                                                       |
| ----------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Per-user local data (scores, preferences)       | Datastore only                                                                                                                                                 |
| Share or centralize data across users           | Datastore + [Firebase](https://docs.pandasuite.com/essentials/components/firebase-session/) or [HTTP](https://docs.pandasuite.com/essentials/components/http/) |
| Cloud backup of user progress                   | JSON export → cloud service                                                                                                                                    |
| Advanced queries or filtering on large datasets | External API                                                                                                                                                   |

## Learn more

- [Variables](https://docs.pandasuite.com/essentials/data/variables/)
- [Collection / List](https://docs.pandasuite.com/essentials/data/collection/)
- [Data binding](https://docs.pandasuite.com/essentials/data/data-binding/)
- [Bookmark / Favorite](https://docs.pandasuite.com/essentials/data/bookmark-favorite/)
- [API & Offline data](https://docs.pandasuite.com/essentials/data/api-offline-data/)
