Model class representing a field in a table.
Field
View sourceimport {base} from '@airtable/blocks';const table = base.getTableByName('Table 1');const field = table.getFieldByName('Name');console.log('The type of this field is', field.type);
Members
class Field extends AbstractModel<FieldData, WatchableFieldKey>
readonly availableAggregators | Array<Aggregator> A list of available aggregators given this field's configuration.
| ||||||
readonly config | FieldConfig The type and options of the field to make type narrowing
| ||||||
readonly description | string | null The description of the field, if it has one. Can be watched.
| ||||||
readonly id | string The ID for this model. | ||||||
readonly isComputed | boolean
| ||||||
readonly isDeleted | boolean
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 | ||||||
readonly isPrimaryField | boolean
| ||||||
readonly name | string The name of the field. Can be watched.
| ||||||
readonly options | FieldOptions | null The configuration options of the field. The structure of the field's
options depend on the field's type.
| ||||||
readonly type | FieldType The type of the field. Can be watched.
| ||||||
checkPermissionsForUpdateDescription | function (description?: string | null) => PermissionCheckResult
Checks whether the current user has permission to perform the given description update. Accepts partial input, in the same format as updateDescriptionAsync. Returns
| ||||||
checkPermissionsForUpdateName | function (name?: undefined | string) => PermissionCheckResult
Checks whether the current user has permission to perform the given name update. Accepts partial input, in the same format as updateNameAsync. Returns
| ||||||
checkPermissionsForUpdateOptions | function (options?: FieldOptions) => PermissionCheckResult
Checks whether the current user has permission to perform the given options update. Accepts partial input, in the same format as updateOptionsAsync. Returns
| ||||||
convertStringToCellValue | function (string: string) => unknown
Attempt to parse a given string and return a valid cell value for the field's current config.
Returns
| ||||||
hasPermissionToUpdateDescription | function (description?: string | null) => boolean
An alias for Checks whether the current user has permission to perform the description update. Accepts partial input, in the same format as updateDescriptionAsync.
| ||||||
hasPermissionToUpdateName | function (name?: undefined | string) => boolean
An alias for Checks whether the current user has permission to perform the name update. Accepts partial input, in the same format as updateNameAsync.
| ||||||
hasPermissionToUpdateOptions | function (options?: FieldOptions) => boolean
An alias for Checks whether the current user has permission to perform the options update. Accepts partial input, in the same format as updateOptionsAsync.
| ||||||
isAggregatorAvailable | function (aggregator: Aggregator | AggregatorKey) => boolean
Checks if the given aggregator is available for this field.
| ||||||
toString | function () => string A string representation of the model for use in debugging. | ||||||
unwatch | function (keys: WatchableFieldKey | ReadonlyArray<WatchableFieldKey>, callback:
Unwatch keys watched with Should be called with the same arguments given to Returns the array of keys that were unwatched. | ||||||
updateDescriptionAsync | function (description: string | null) => Promise<void>
Updates the description for this field. To remove an existing description, pass Throws an error if the user does not have permission to update the field, or if an invalid description is provided. This action is asynchronous. Unlike updates to cell values, updates to field descriptions are
not applied optimistically locally. You must
| ||||||
updateNameAsync | function (name: string) => Promise<void>
Updates the name for this field. Throws an error if the user does not have permission to update the field, or if an invalid name is provided. This action is asynchronous. Unlike updates to cell values, updates to field name are
not applied optimistically locally. You must
| ||||||
updateOptionsAsync | function (options: FieldOptions, opts: UpdateFieldOptionsOpts = {}) => Promise<void>
Updates the options for this field. Throws an error if the user does not have permission to update the field, if invalid options are provided, if this field has no writable options, or if updates to this field type is not supported. Refer to FieldType for supported field types, the write format for options, and other specifics for certain field types. This action is asynchronous. Unlike updates to cell values, updates to field options are
not applied optimistically locally. You must Optionally, you can pass an
| ||||||
watch | function (keys: WatchableFieldKey | ReadonlyArray<WatchableFieldKey>, callback:
Get notified of changes to the model. Every call to Returns the array of keys that were watched. |