# Record

**Kind:** Class

Model class representing a record in a table.

Do not instantiate. You can get instances of this class by calling `useRecords`.

## Properties

### `createdTime`

Type: `Date`

The created time of this record.

```js
console.log(`
    This record was created at ${myRecord.createdTime.toISOString()}
`);
```

### `id`

Type: `string`

The ID for this model.

### `isDeleted`

Type: `boolean`

`true` if the model has been deleted, and `false` otherwise.

In general, it's best to avoid keeping a reference to an object past the
current event loop, since it may be deleted and trying to access any data
of a deleted object (other than its ID) will throw. But if you keep a
reference, you can use `isDeleted` to check that it's safe to access the
model's data.

### `name`

Type: `string`

The primary cell value in this record, formatted as a `string`.

```js
console.log(myRecord.name);
// => '42'
```

## Methods

### `fetchForeignRecordsAsync(field, filterString)`

Fetch foreign records for a field. Subsequent calls to this method will
override previous calls that are still pending. The previous call(s)
will immediately resolve with an empty `records` array.

**Parameters:**
- `field` (`Field`)
- `filterString` (`string`) — The filter string to use to filter the records.

**Returns:** `Promise<object>`

### `getCellValue(fieldOrFieldIdOrFieldName)`

Gets the cell value of the given field for this record.

**Parameters:**
- `fieldOrFieldIdOrFieldName` (`Field | FieldId | string`) — The field (or field ID or field name) whose cell value you'd like to get.

**Returns:** `unknown`

```js
const cellValue = myRecord.getCellValue(mySingleLineTextField);
console.log(cellValue);
// => 'cell value'
```

### `getCellValueAsString(fieldOrFieldIdOrFieldName)`

Gets the cell value of the given field for this record, formatted as a `string`.

**Parameters:**
- `fieldOrFieldIdOrFieldName` (`Field | FieldId | string`) — The field (or field ID or field name) whose cell value you'd like to get.

**Returns:** `string`

```js
const stringValue = myRecord.getCellValueAsString(myNumberField);
console.log(stringValue);
// => '42'
```

### `toString()`

A string representation of the model for use in debugging.

**Returns:** `string`

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

Unwatch keys watched with `.watch`.

Should be called with the same arguments given to `.watch`.

Returns the array of keys that were unwatched.

**Parameters:**
- `keys` (`WatchableRecordKeyCore | WatchableRecordKey | ReadonlyArray<WatchableRecordKeyCore | WatchableRecordKey>`) — the keys to unwatch
- `callback` (`object`) — the function passed to `.watch` for these keys
- `context?` (`FlowAnyObject | null`) — the context that was passed to `.watch` for this `callback`

**Returns:** `Array<WatchableRecordKeyCore | WatchableRecordKey>`

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

Get notified of changes to the model.

Every call to `.watch` should have a matching call to `.unwatch`.

Returns the array of keys that were watched.

**Parameters:**
- `keys` (`WatchableRecordKeyCore | WatchableRecordKey | ReadonlyArray<WatchableRecordKeyCore | WatchableRecordKey>`) — the keys to watch
- `callback` (`object`) — a function to call when those keys change
- `context?` (`FlowAnyObject | null`) — an optional context for `this` in `callback`.

**Returns:** `Array<WatchableRecordKeyCore | WatchableRecordKey>`
