Model class representing a base.
If you want the base model to automatically recalculate whenever the base schema changes, try the useBase hook. Alternatively, you can manually subscribe to changes with useWatchable (recommended) or Base#watch.
Press shift + S to search API reference.
Model class representing a base.
If you want the base model to automatically recalculate whenever the base schema changes, try the useBase hook. Alternatively, you can manually subscribe to changes with useWatchable (recommended) or Base#watch.
import {base} from '@airtable/blocks';console.log('The name of your base is', base.name);
class Base extends AbstractModel<BaseData, WatchableBaseKey>
readonly activeCollaborators | Array<CollaboratorData> The users who have access to this base.
| ||||||
readonly color | string The color of the base.
| ||||||
readonly id | string The ID for this model. | ||||||
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 name | string The name of the base.
| ||||||
readonly tables | Array<Table> The tables in this base. Can be watched to know when tables are created, deleted, or reordered in the base.
| ||||||
readonly workspaceId | string The workspace id of the base.
| ||||||
checkPermissionsForCreateTable | function (name?: undefined | string, fields?: Array<{
Checks whether the current user has permission to create a table. Accepts partial input, in the same format as createTableAsync. Returns
| ||||||
createTableAsync | function (name: string, fields: Array<{
Creates a new table. Throws an error if the user does not have permission to create a table, if an invalid table name is provided, or if invalid fields are provided (invalid name, type, options or description). Refer to FieldType for supported field types, the write format for field options, and other specifics for certain field types. At least one field must be specified. The first field in the A default grid view will be created with all fields visible. This action is asynchronous. Unlike new records, new tables are not created
optimistically locally. You must
| ||||||
getCollaborator | function (idOrNameOrEmail: UserId | string) => CollaboratorData | null The user matching the given ID, name, or email address. Throws if that user does not exist or does not have access to this base. Use getCollaboratorIfExists instead if you are unsure whether a collaborator with the given ID exists and has access to this base. This method is convenient when building an extension for a specific base, but for more generic extensions the best practice is to use the getCollaboratorById method instead. | ||||||
getCollaboratorById | function (collaboratorId: UserId) => CollaboratorData
The user matching the given ID. Throws if that user does not exist or does not have access to this base. Use getCollaboratorByIdIfExists instead if you are unsure whether a collaborator with the given ID exists and has access to this base. | ||||||
getCollaboratorByIdIfExists | function (collaboratorId: UserId) => CollaboratorData | null
The user matching the given ID, or | ||||||
getCollaboratorIfExists | function (idOrNameOrEmail: UserId | string) => CollaboratorData | null The user matching the given ID, name, or email address. Returns null if that user does not exist or does not have access to this base. This method is convenient when building an extension for a specific base, but for more generic extensions the best practice is to use the getCollaboratorByIdIfExists method instead. | ||||||
getMaxRecordsPerTable | function () => number Returns the maximum number of records allowed in each table of this base. | ||||||
getTable | The table matching the given ID or name. Throws if no matching table exists within this base. Use getTableIfExists instead if you are unsure whether a table exists with the given name/ID. This method is convenient when building an extension for a specific base, but for more generic extensions the best practice is to use the getTableById or getTableByName methods instead. | ||||||
getTableById | function (tableId: string) => Table
The table matching the given ID. Throws if that table does not exist in this base. Use getTableByIdIfExists instead if you are unsure whether a table exists with the given ID. | ||||||
getTableByIdIfExists | function (tableId: string) => Table | null
The table matching the given ID, or | ||||||
getTableByName | function (tableName: string) => Table
The table matching the given name. Throws if no table exists with that name in this base. Use getTableByNameIfExists instead if you are unsure whether a table exists with the given name. | ||||||
getTableByNameIfExists | function (tableName: string) => Table | null
The table matching the given name, or | ||||||
getTableIfExists | The table matching the given ID or name. Returns This method is convenient when building an extension for a specific base, but for more generic extensions the best practice is to use the getTableByIdIfExists or getTableByNameIfExists methods instead. | ||||||
hasPermissionToCreateTable | function (name?: undefined | string, fields?: Array<{
An alias for Checks whether the current user has permission to create a table. Accepts partial input, in the same format as createTableAsync.
| ||||||
toString | function () => string A string representation of the model for use in debugging. | ||||||
unwatch | function (keys: WatchableBaseKey | ReadonlyArray<WatchableBaseKey>, callback:
Unwatch keys watched with Should be called with the same arguments given to Returns the array of keys that were unwatched. | ||||||
watch | function (keys: WatchableBaseKey | ReadonlyArray<WatchableBaseKey>, callback:
Get notified of changes to the model. Every call to Returns the array of keys that were watched. |