export const meta = {
  title: `Data management`,
  description: `Get started with Amplify Studio`,
};

The Amplify Studio **Data management** view provides a tabular view of the backend data for an application. You can use this feature to test your models and to provide both technical and non-technical team members with the ability to create and update an application's data in real-time instead of building admin views.

![cms](/images/console/cms.png)

The [Data modeling](/console/data/data-model) documentation guides you through several examples for creating data models and setting the relationships between them. The following data management procedures, reference the *Book* and *Author* tables that were created in the data modeling example in order to demonstrate how to perform operations on your data.

## To create data
1. [Launch Studio](/console/adminui/start/#log-into-the-amplify-console) for an app.
2. On the **Manage** menu, choose **Content**.
3. On the **Content** page, select the table to update from the **Select table** menu. For this example, select the *Author* table.
4. Choose **Create author**.
5. In the **Add Author** window, specify your custom values for the fields in the table. For this example, enter *Martha* for the *firstName* field and enter *Riviera* for the *lastName* field.
6. Choose **Submit**.

## To seed data
1. [Launch Studio](/console/adminui/start/#log-into-the-amplify-console) for an app.
2. On the **Manage** menu, choose **Content**.
3. On the **Content** page, select the table to update from the **Select table** menu. For this example, select the *Author* table.
4. On the **Actions** menu, choose **Auto-generate data**.
5. In the **Auto-generate data** window, specify how many rows of data you want to generate and constraints for the generated data. 
6. Choose **Generate data**. Seed data is auto-generated using [Faker](https://faker.readthedocs.io/en/master/). 

<Callout warning={true}>

**Warning** - Seed data cannot be generated for tables that have the following field types: AWSPhone, Enum, Custom Type, or Relationship

</Callout>

## To edit data
1. [Launch Studio](/console/adminui/start/#log-into-the-amplify-console) for an app.
2. On the **Manage** menu, choose **Content**.
3. On the **Content** page, select the table to update from the **Select table** menu. For this example, select the *Author* table that you used in the previous procedure.
4. From the list of records, select any field in the record you want to update.
5. In the **Edit Author** window, make any changes to your record, and then choose **Submit**.

## To create and link data
When you create a new instance in a table, you can also link it to an instance in another table based on the relationships between the data models. 

1. [Launch Studio](/console/adminui/start/#log-into-the-amplify-console) for an app.
2. On the **Manage** menu, choose **Content**.
3. On the **Content** page, select the table to update from the **Select table** menu. For this example, select the *Book* table, to add a new instance of a book. 
4. Choose **Create book**. For *title*, enter *All About Dogs*. 
5. Let's link this book to the *Martha Rivera* author instance that you edited in the previous procedure. Choose **Link to an existing Author**, then choose the ID for *Martha Rivera* from the list of *Author* instances. Note that you have the option to link to an an author because a relationship was defined between the *Book* and *Author* tables during the data modeling process.
6. View the details for the *All About Dogs* instance in the *Book* table, and *Martha Rivera* is linked as an author. 

Alternatively, you can save save *All About Dogs* before linking to an Author, and instead create the link from an Author record by opening the *Martha Rivera* record, and selecting *All About Dogs* from the related Books.

## To delete data
1. [Launch Studio](/console/adminui/start/#log-into-the-amplify-console) for an app.
2. On the **Manage** menu, choose **Content**.
3. On the **Content** page, select the table to update from the **Select table** menu. For this example, select the *Author* table that you used in the previous procedure.
4. From the list of records in the table, select the checkbox to the left of the record(s) you want to delete. For this example, select *Martha Rivera*. 
5. On the **Actions** menu, then choose **Delete**.
6. In the **Delete item** confirmation window, choose **Delete**.

## To download data
1. [Launch Studio](/console/adminui/start/#log-into-the-amplify-console) for an app.
2. On the **Manage** menu, choose **Content**.
3. On the **Actions** menu you have two options for downloading data.
  1. Choose **Download selected items (.csv)** to download only the selected rows of data.
  2. Choose **Download all items (.csv)** to download all rows of data on the currently selected model.
4. Once you have selected a download option, your data should immediately start downloading as a CSV.

## Limitations

### Conflict Resolution
Amplify Studio's data manager requires your app to have Conflict Resolution enabled. 

For applications that are using a GraphQL API with Conflict Resolution disabled, app data can be managed using **GraphiQL**, a visual interface for building and executing queries and mutations in GraphQL. [Learn more about GraphQL in their documentation.](https://graphql.org/learn/)

To use the data manager, you can [adjust your GraphQL API settings.](/console/data/data-model/#datastore-and-graphql)

### Null required fields
When using the data manager, you may encounter the following error message:

```console

Field {{fieldName}} cannot be set to null since it's a required field.

```

This message occurs when there are records in the selected data model that have null values for required fields. Usually, this occurs because a field was changed to be required after records were created. To resolve this issue, null records need to be updated.

*To update records in Studio...*
1. From the Data tab, change the required field to optional, and select **Save and deploy** to redeploy your data model
1. In the **Content** tab, update all records so that there are no null values for this field, or delete records with null values
1. In the Data tab, change the field back to required, and select **Save and deploy** again

*To update records in DynamoDB...*
1. Visit the [DynamoDB console](https://console.aws.amazon.com/dynamodbv2/home)
1. Select the **Tables** heading in the left-hand nav bar, and select your app's table
1. Select the "Explore table items" button in the upper right-hand corner
1. Update all records so that there are no null values for this field, or delete records with null values

### Bi-directionally required fields

A bi-directionally required field is a Relationship field between two data models where both models require a non-null value for the field. Currently, the Data Manager does not support creating or editing records for models with bi-directionally required fields. To manage data in these models, take one of two paths:
1. Change the field to optional for one or both of the related models, OR
1. Create and manage records using GraphiQL, which supports simultaneous record management

### Change of type in fields
When using the data manager, you may encounter the following error message:

```console

Field {{fieldName}} has a type mismatch. Expected {{typeName}}, but got {{typeName}}

```

This message occurs when there are records in the selected data model that have a mismatch in the expected type of a field. Usually, this occurs because a field was updated with a new type after records were created. To resolve this issue, records need to be updated.

*To update records in Studio...*
1. In the **Content** tab, update all records so that they match the type of this field

*To update records in DynamoDB...*
1. Visit the [DynamoDB console](https://console.aws.amazon.com/dynamodbv2/home)
1. Select the **Tables** heading in the left-hand nav bar, and select your app's table
1. Select the "Explore table items" button in the upper right-hand corner
1. Update all records so that they match the type of this field

### Multi-tab limitation

Studio's Data Manager requires use of indexedDB in order to function. Because of this, Data Manager may not load as expected if opened in multiple tabs or windows in your browser. For expected performance of Data Manager, ensure it is only open in one tab at a time.

### IAM required as auth provider

In order to use Data Manager, your app must have IAM set as the default or an additional auth provider. If IAM is not added as an auth provider, you may receive the following error message:

<Callout info>
IAM is required as an auth provider to use content management capabilities. To automatically add IAM and enable content management, navigate to ‘Data’ and select ‘Save and Deploy’.
</Callout>

**For Studio-supported GraphQL schemas...**
1. Navigate to the Data tab
1. Click "Save and Deploy" and Studio will automatically add IAM as an additional auth provider

**For unsupported GraphQL schemas...**
1. In your app root directory, run `amplify update api`
1. Select `GraphQL`
1. Select `Authorization Modes`
1. Change your default auth type OR add an additional auth type

*Change your default auth type:*
1. Select IAM as your default authorization type
1. Run `amplify push`

*Add an additional auth type:*
1. Select your current default authorization type and accept all defaults to leave it unchanged
1. Select `Configure additional auth types`
1. Select IAM
1. Run `amplify push`
