# Using Collection View

For [MongoDB](https://docs.tonic.ai/app/setting-up-your-database/mongodb) and [Amazon DynamoDB](https://docs.tonic.ai/app/setting-up-your-database/dynamodb), **Collection View** replaces **Database View** and **Table View**. From **Collection View**, you can view the fields in a selected collection. You can then assign a collection mode to the collection, and assign generators to fields.

<figure><img src="https://3378426797-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LSQCLFQ4bslJ-HYc8c3%2Fuploads%2F2v5Gsb8xBScntDHEUUaR%2FMongoDBCollectionView.png?alt=media&#x26;token=ac407014-725b-441c-b740-a22a29d5da68" alt=""><figcaption><p>Collection View for a MongoDB workspace</p></figcaption></figure>

## Selecting the collection to view

From the **Collection** dropdown list, select the collection to view.

## Assigning a collection mode to the collection <a href="#mongodb-collection-view-collection-mode" id="mongodb-collection-view-collection-mode"></a>

Collection mode is the term used for table mode. The collection mode determines at the collection level how Structural uses the collection data to generate the destination database.

### Available collection modes <a href="#collection-modes-available" id="collection-modes-available"></a>

By default, the collection mode is De-Identify. In this mode, Structural uses the assigned generators to transform the source database into the destination database.

For [MongoDB](https://docs.tonic.ai/app/setting-up-your-database/mongodb) and [DynamoDB](https://docs.tonic.ai/app/setting-up-your-database/dynamodb), the only other options are Truncate and Preserve Destination.

* Truncate means that only the collection structure is included in the destination database. The collection has no data in the destination database.
* Preserve Destination means that Tonic does not change the data that is currently in the destination database.

### Assigning the collection mode <a href="#collection-mode-assign" id="collection-mode-assign"></a>

{% hint style="info" %}
**Required workspace permission:** Assign table modes
{% endhint %}

To assign the collection mode:

1. Click the **Collection Mode** dropdown list.
2. On the panel, click the current collection mode.
3. From the drop-down list, select the mode to use.

## Selecting the type of view <a href="#mongodb-collection-view-select-view-type" id="mongodb-collection-view-select-view-type"></a>

You can view a collection either as a hybrid document or as single documents. From the **View** dropdown list, select the view to use.

### Hybrid document view <a href="#collection-view-hybrid" id="collection-view-hybrid"></a>

The default view is **Hybrid Document**. For the hybrid document view, the key list reflects all of the permutations of every field from every document. For example, a field might sometimes be a datetime value and sometimes a string. Hybrid document view lists both types.

<figure><img src="https://3378426797-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LSQCLFQ4bslJ-HYc8c3%2Fuploads%2F2v5Gsb8xBScntDHEUUaR%2FMongoDBCollectionView.png?alt=media&#x26;token=ac407014-725b-441c-b740-a22a29d5da68" alt=""><figcaption><p>Hybrid Document view of Collection View</p></figcaption></figure>

### Single document view <a href="#collection-view-single-document" id="collection-view-single-document"></a>

**Single Document** view displays a single document at a time. You can then page through up to 100 documents. **Single Document** view displays the structure for each document.

<figure><img src="https://3378426797-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LSQCLFQ4bslJ-HYc8c3%2Fuploads%2FO4h1FWYJI3iGt0EhMQT4%2FMongoDBCollectionViewSingleDoc.png?alt=media&#x26;token=b82e7f78-d73f-4f30-b955-75dded0dbf39" alt=""><figcaption><p>Single Document view of Collection View</p></figcaption></figure>

## Information on the field list <a href="#mongodb-collection-view-field-list-information" id="mongodb-collection-view-field-list-information"></a>

For each field, **Collection View** always displays:

* The field name and type.
* For fields that you configured as primary or foreign keys, a key icon.
* The assigned generator.
* An example value. For the hybrid view, you can use the magnifying glass icon to display additional example values.

For the hybrid document view, there is also a **Field Freq** column. **Field Freq** shows the percentage of documents that contain that permutation of field and type.

For example, a field might be Null 33% of the time and contain a numeric value 67% of the time. Or a field value might be an Int32 value 3% of the time and an Int64 value 6% of the time. The percentages apply to the first 100 documents.

## Toggling between source and preview data <a href="#mongodb-collection-view-toggle-preview" id="mongodb-collection-view-toggle-preview"></a>

{% hint style="info" %}
**Required workspace permission:**

* **Source data:** Preview source data
* **Destination data:** Preview destination data
  {% endhint %}

The **Preview** toggle at the top right of **Collection View** allows you to choose whether to display original source data or the transformed data. You can switch back and forth to determine exactly how Tonic Structural transforms the data based on the collection and field configuration.

By default, the **Preview** toggle is in the on position, and the displayed data reflects the selected collection mode and the assigned generators. For collections that use Truncate mode, the preview data is empty. Truncated collections do not have data in the destination database.

To display the original source data, toggle **Preview** to the off position.

## Filtering collection fields <a href="#collection-view-filter-fields" id="collection-view-filter-fields"></a>

In the single document view, you can filter the fields by either the field name or the field value.

In the hybrid document view, you can filter the fields based on either the field name or field properties.

### Filtering single document view by field name or value <a href="#collection-view-filter-single" id="collection-view-filter-single"></a>

You can filter single document view to only display fields that have specific text in either the field name or the field value.

To filter by value, toggle **Search by Value** to the on position.

<figure><img src="https://3378426797-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LSQCLFQ4bslJ-HYc8c3%2Fuploads%2FrwKp8bWxUK77fTPwdOrZ%2FMongoDBCollectionViewSingleFilter.png?alt=media&#x26;token=ad026bd5-db86-4ca3-a286-c3876e01c218" alt=""><figcaption><p>Filter field and Search by Value toggle for single document view</p></figcaption></figure>

After you select the filter type, in the search field, type text that is in the field name or value. As you type, Structural filters the list to only include fields that contain the filter text.

### Filtering hybrid view by field name <a href="#collection-view-filter-hybrid-field-name" id="collection-view-filter-hybrid-field-name"></a>

To filter hybrid view by field name, in the search field, begin to type text that is in the field name. As you type, Structural filters the list to only include fields with names that include the filter text.

<figure><img src="https://3378426797-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LSQCLFQ4bslJ-HYc8c3%2Fuploads%2FrXydXyV6oqhN4hKejpTu%2FMongoDBCollectionViewHybridFilterField.png?alt=media&#x26;token=05abcab8-5147-4f35-8026-301f0d62a878" alt=""><figcaption><p>Filter field and Filters button for hybrid view</p></figcaption></figure>

### Filtering hybrid view by field properties <a href="#collection-view-filter-hybrid-field-props" id="collection-view-filter-hybrid-field-props"></a>

From the hybrid document view, you can filter the fields based on field properties.

To display the **Filters** panel, click **Filters**.

<figure><img src="https://3378426797-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LSQCLFQ4bslJ-HYc8c3%2Fuploads%2FHCaRqByUxDKQB5w5oQLJ%2FMongoDBCollectionViewHybridFilterPanel.png?alt=media&#x26;token=3a8ae2b8-ac97-4b75-a22f-fcac947bf0a9" alt=""><figcaption><p>Filters panel for hybrid view on Collection View</p></figcaption></figure>

#### **Searching for a filter** <a href="#collection-view-filter-hybrid-search" id="collection-view-filter-hybrid-search"></a>

To search for a filter or a filter value, in the search field, start to type the value. The search looks for text in the individual settings.

#### **Adding a filter** <a href="#collection-view-filter-hybrid-add" id="collection-view-filter-hybrid-add"></a>

To add a filter, depending on the filter type, either check the checkbox or select a filter option. As you add filters, Structural applies them to the field list.

Above the list, Structural displays tags for the selected filters.

#### **Clearing the selected filters** <a href="#collection-view-filter-hybrid-clear" id="collection-view-filter-hybrid-clear"></a>

To clear all of the currently selected filters, click **Clear All**.

## Filters panel filters <a href="#collection-view-filters-panel-filters" id="collection-view-filters-panel-filters"></a>

The **Filters** panel in hybrid view includes the following fields.

### At-risk fields <a href="#collection-view-filter-panel-at-risk" id="collection-view-filter-panel-at-risk"></a>

An at-risk field:

* Is marked as sensitive
* Is assigned the Passthrough generator.

To only display at-risk fields, on the **Filters** panel, check **At-Risk Field**.

When you check **At-Risk Field**, Structural adds the following filters under **Privacy Settings**:

* Sets the sensitivity filter to **Sensitive**.
* Sets the protection status filter to **Not protected**.

### Sensitivity <a href="#collection-view-filter-panel-sensitivity" id="collection-view-filter-panel-sensitivity"></a>

You can filter the fields based on the field sensitivity.

On the **Filters** panel, under **Privacy Settings**, the sensitivity filter is by default set to **All**, which indicates to display both sensitive and non-sensitive fields.

* To only display sensitive fields, click **Sensitive**.
* To only display non-sensitive fields, click **Not sensitive**.

Note that when you check **At-risk Field**, Structural automatically selects **Sensitive**.

### Protection status <a href="#collection-view-filter-panel-protection" id="collection-view-filter-panel-protection"></a>

You can filter the fields based on whether they have any generator other than Passthrough assigned.

On the **Filters** panel, under **Privacy Settings**, the field protection filter is by default set to **All**, which indicates to display both protected and not protected fields.

* To only display fields that have an assigned generator, click **Protected**.
* To only display fields that do not have an assigned generator, click **Not protected**.

Note that when you check **At-Risk Field**, Structural automatically selects **Not protected**.

### Recommended generators <a href="#collection-view-filter-panel-recommended-generators" id="collection-view-filter-panel-recommended-generators"></a>

When Structural detects that a field is sensitive, it can also determine a recommended generator.

For example, when it detects a name value, it also recommends the Name generator.

You can filter the fields to display the fields that have recommended generators.

On the **Filters** panel, under **Recommended Generators**, check the checkbox next to the recommended generator for which to display the fields that have that recommendation.

### Field data type <a href="#collection-view-filter-panel-data-type" id="collection-view-filter-panel-data-type"></a>

You can filter the fields by the field data type. For example, you might only display columns that contain either numeric or integer values.

To only display fields that have specific data types, on the **Filters** panel, under **Database Data Types**, check the checkbox for each data type to include.

The list of data types only includes data types that are present in the currently displayed fields and that are compatible with other applied filters.

To search for a specific data type, in the **Filters** search field, begin to type the data type.

### Unresolved schema changes <a href="#collection-view-filter-panel-schema-changes" id="collection-view-filter-panel-schema-changes"></a>

When the source database schema changes, you might need to update the configuration to reflect those changes. If you do not resolve the schema changes, then the data generation might fail. The data generation fails if there are unresolved conflicting changes, or if you configure Structural to always fail data generation when there are any unresolved changes.

For more information about schema changes, go to [schema-changes](https://docs.tonic.ai/app/generation/schema-changes "mention").

To only display fields that have unresolved schema changes, on the **Filters** panel, check **Unresolved Schema Changes**.

### Sensitivity type <a href="#collection-view-filter-panel-sensitivity-type" id="collection-view-filter-panel-sensitivity-type"></a>

For detected sensitive fields, the sensitivity type indicates the type of data that was detected. Examples of sensitivity types include First Name, Address, and Email.

To only display fields that contain specific sensitivity types, on the **Filters** panel, under **Sensitivity Type**, check the checkbox for each sensitivity type to include.

The list of sensitivity types only includes sensitivity types that are present in the currently displayed fields.

To search for a specific sensitivity type, in the **Filters** search field, type the sensitivity type.

### Sensitivity confidence

When the Structural sensitivity scan identifies a value as belonging to a sensitivity type, it also determines how confident it is in that determination.

You can filter the columns based on the confidence level.

To only display columns that have a specific confidence level, on the **Filters** panel, under **Sensitivity confidence**, check the checkbox next to each confidence level to include.

### Primary or foreign keys <a href="#collection-view-filter-panel-keys" id="collection-view-filter-panel-keys"></a>

You can filter the column list to indicate whether to include:

* Columns that are not primary or foreign keys.
* Columns that are foreign keys.
* Columns that are primary keys.

On the **Filters** panel, under **Field Type**:

* To display fields that are neither a primary key nor a foreign key, check **Non-keyed**.
* To display fields that are primary keys, check **Primary key**.
* To display fields that are foreign keys, check **Foreign key**.

## Commenting on fields <a href="#mongodb-collection-view-field-comments" id="mongodb-collection-view-field-comments"></a>

{% hint style="info" %}
**Required license:** Professional or Enterprise
{% endhint %}

You can add comments to fields. For example, you might use a comment to explain why you selected a particular generator or marked a field as sensitive or not sensitive.

### Adding a new comment <a href="#collection-view-comment-new" id="collection-view-comment-new"></a>

If a field does not have any comments, then to add a comment:

1. Click the comment icon.
2. In the comment field, type the comment text.
3. Click **Comment**.

### Replying to an existing comment <a href="#collection-view-comment-reply" id="collection-view-comment-reply"></a>

When a field has existing comments, the comment icon is green. To add comments:

1. Click the comment icon.\
   \
   The comments panel shows the previous comments. Each comment includes the comment user and timestamp.
2. In the comment field, type the comment text.
3. Click **Reply**.

## Indicating whether a field is sensitive <a href="#mongodb-collection-view-field-sensitivity" id="mongodb-collection-view-field-sensitivity"></a>

{% hint style="info" %}
**Required workspace permission:** Configure column sensitivity
{% endhint %}

On the field configuration panel, the sensitivity toggle at the top right indicates whether the field is marked as sensitive.

To mark a field as sensitive, toggle the setting to the **Sensitive** position.

To mark a field as not sensitive, toggle the setting to the **Not Sensitive** position.

## Assigning a generator to a field and type <a href="#mongodb-collection-view-assign-generator" id="mongodb-collection-view-assign-generator"></a>

{% hint style="info" %}
**Required workspace permission:** Configure column generators
{% endhint %}

You can assign a generator to each combination of field and type. For example, depending on the document, the data type for a field might be either string or integer. You can indicate to use the Character Scramble generator when the field type is a string and the Random Integer generator when the field type is integer.

In hybrid document view, the Null type reflects when the column value is Null. You do not assign a generator to it.

To assign a generator:

1. Click the generator value for the field.
2. On the configuration panel, from the **Generator Type** dropdown list, select the generator.
3. Configure the generator options. For details about the available configuration options for each generator, go to the [generator-reference](https://docs.tonic.ai/app/generation/generators/generator-reference "mention").

## Assigning generators to fields that match JSONPath expressions <a href="#collection-view-path-expressions" id="collection-view-path-expressions"></a>

In addition to assigning generators to individual fields, you can assign generators to generic paths. The paths use JSONPath syntax.

For more information, go to [document-path-expressions](https://docs.tonic.ai/app/generation/working-with-document-based-data/document-path-expressions "mention").

## Disabling examples for sparse collections <a href="#collection-config-disable-sparse-examples" id="collection-config-disable-sparse-examples"></a>

By default, Structural retrieves 100 documents. It then uses the data in these documents to populate example values in the hybrid document.

For sparsely populated collections, where less common fields are not present in those 100 documents, Structural retrieves extra documents until it has example values for all fields. For very sparsely populated collections, this might cause the collection view to load slowly, because it must retrieve many documents.

To disable examples for sparse collections, set the [environment setting](https://docs.tonic.ai/app/admin/environment-variables-setting) `TONIC_MONGO_DISABLE_EXTRA_EXAMPLES` to `true`. You can add this setting manually to the **Environment Settings** list on **Structural Settings**.

Note that this setting applies to both MongoDB and Amazon DynamoDB.

When this setting is `true`, fields that do not have a retrieved value use a dummy default value that is based on the data type.
