# ViewMetadataQueryResult

**Kind:** Class

Contains information about a view that isn't loaded by default e.g. field order and visible fields.

In a React component, we recommend using `useViewMetadata` instead.

```js
async function loadMetadataForViewAsync(view) {
    const viewMetadata = view.selectMetadata();
    await viewMetadata.loadDataAsync();

    console.log(viewMetadata.visibleFields);
    // => [Field, Field, Field]

    console.log(viewMetadata.allFields);
    // => [Field, Field, Field, Field, Field]

    viewMetadata.unloadData();
}
```

## Properties

### `allFields`

Type: `Array<Field>`

Returns every field in the table in the order they appear in this view. Watchable.

### `id`

Type: `string`

The ID for this model.

### `isDataLoaded`

Type: `boolean`

### `isDeleted`

Type: `boolean`

### `visibleFields`

Type: `Array<Field>`

Returns every field visible in this view. Watchable.

### `parentView`

Type: `View`

## Methods

### `loadDataAsync()`

Will cause all the async data to be fetched and retained. Every call to
`loadDataAsync` should have a matching call to `unloadData`.

Returns a Promise that will resolve once the data is loaded.

**Returns:** `Promise<void>`

### `toString()`

A string representation of the model for use in debugging.

**Returns:** `string`

### `unloadData()`

**Returns:** `void`

### `unwatch(keys, callback, context?)`

Unwatching a key that needs to load data asynchronously will automatically
cause the data to be released. Once the data is available, the callback
will be called.

**Parameters:**
- `keys` (`WatchableViewMetadataKey | ReadonlyArray<WatchableViewMetadataKey>`)
- `callback` (`FlowAnyFunction`)
- `context?` (`FlowAnyObject | null`)

**Returns:** `Array<WatchableViewMetadataKey>`

### `watch(keys, callback, context?)`

Watching a key that needs to load data asynchronously will automatically
cause the data to be fetched. Once the data is available, the callback
will be called.

**Parameters:**
- `keys` (`WatchableViewMetadataKey | ReadonlyArray<WatchableViewMetadataKey>`)
- `callback` (`FlowAnyFunction`)
- `context?` (`FlowAnyObject | null`)

**Returns:** `Array<WatchableViewMetadataKey>`
