The fields in this table. The order is arbitrary, since fields are
only ordered in the context of a specific view.
Can be watched to know when fields are created or deleted.
console.log(`This table has ${myTable.fields.length} fields`);
readonly id
string
The ID for this model.
readonly isDeleted
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.
Returns {hasPermission: true} if the current user can update the specified record,
{hasPermission: false, reasonDisplayString: string} otherwise. reasonDisplayString may be
used to display an error message to the user.
object mapping FieldId or field name to value for that field.
Checks whether the current user has permission to create the specified record.
Accepts partial input, in the same format as createRecordAsync.
The more information provided, the more accurate the permissions check will be.
Returns {hasPermission: true} if the current user can create the specified record,
{hasPermission: false, reasonDisplayString: string} otherwise. reasonDisplayString may be
used to display an error message to the user.
// Check if user can create a specific record, when you already know what
Array of objects mapping FieldId or field name to value for that field.
Checks whether the current user has permission to create the specified records.
Accepts partial input, in the same format as createRecordsAsync.
The more information provided, the more accurate the permissions check will be.
Returns {hasPermission: true} if the current user can create the specified records,
{hasPermission: false, reasonDisplayString: string} otherwise. reasonDisplayString may be
used to display an error message to the user.
// Check if user can create specific records, when you already know what
// fields/cell values will be set for the records.
Checks whether the current user has permission to delete the specified record.
Accepts optional input, in the same format as deleteRecordAsync.
The more information provided, the more accurate the permissions check will be.
Returns {hasPermission: true} if the current user can delete the specified record,
{hasPermission: false, reasonDisplayString: string} otherwise. reasonDisplayString may be
used to display an error message to the user.
Checks whether the current user has permission to delete the specified records.
Accepts optional input, in the same format as deleteRecordsAsync.
The more information provided, the more accurate the permissions check will be.
Returns {hasPermission: true} if the current user can delete the specified records,
{hasPermission: false, reasonDisplayString: string} otherwise. reasonDisplayString may be
used to display an error message to the user.
cell values to update in that record, specified as object mapping FieldId or field name to value for that field.
Checks whether the current user has permission to perform the given record update.
Accepts partial input, in the same format as updateRecordAsync.
The more information provided, the more accurate the permissions check will be.
Returns {hasPermission: true} if the current user can update the specified record,
{hasPermission: false, reasonDisplayString: string} otherwise. reasonDisplayString may be
used to display an error message to the user.
// Check if user can update specific fields for a specific record.
const updateRecordCheckResult =
table.checkPermissionsForUpdateRecord(record,{
'Post Title':'How to make: orange-mango pound cake',
Array of objects containing recordId and fields/cellValues to update for that record (specified as an object mapping FieldId or field name to cell value)
Checks whether the current user has permission to perform the given record updates.
Accepts partial input, in the same format as updateRecordsAsync.
The more information provided, the more accurate the permissions check will be.
Returns {hasPermission: true} if the current user can update the specified records,
{hasPermission: false, reasonDisplayString: string} otherwise. reasonDisplayString may be
used to display an error message to the user.
const recordsToUpdate =[
{
// Validating a complete record update
id: record1.id,
fields:{
'Post Title':'How to make: orange-mango pound cake',
'Publication Date':'2020-01-01',
},
},
{
// Like updateRecordsAsync, fields can be specified by name or ID
name for the field. must be case-insensitive unique
type
type for the field
options
options for the field. omit for fields without writable options
description
description for the field. is optional and will be '' if not specified
or if specified as null.
Creates a new field.
Similar to creating a field from the Airtable UI, the new field will not be visible
in views that have other hidden fields and views that are publicly shared.
Throws an error if the user does not have permission to create a field, if invalid
name, type or options are provided, or if creating fields of this 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 new records, new fields are not created
optimistically locally. You must await the returned promise before using the new
field in your extension.
This action is asynchronous: await the returned promise if you wish to wait for the new
record to be persisted to Airtable servers.
Updates are applied optimistically locally, so your changes will be reflected in your extension
before the promise resolves.
The returned promise will resolve to the RecordId of the new record once it is persisted.
You may only create up to 50 records in one call to createRecordsAsync.
See Write back to Airtable for
more information about write limits.
This action is asynchronous: await the returned promise if you wish to wait for the new
record to be persisted to Airtable servers.
Updates are applied optimistically locally, so your changes will be reflected in your extension
before the promise resolves.
The returned promise will resolve to an array of RecordIds of the new records once the new
records are persisted.
const recordDefs =[
// Fields can be specified by name or ID
{
fields:{
'Project Name':'Advertising campaign',
'Budget':100,
},
},
{
fields:{
[projectNameField.id]:'Cat video',
[budgetField.id]:200,
},
},
// Specifying no fields will create a new record with no cell values set
{
fields:{},
},
// Cell values should generally have format matching the output of
// record.getCellValue() for the field being updated
Throws an error if the user does not have permission to delete the given record.
This action is asynchronous: await the returned promise if you wish to wait for the
delete to be persisted to Airtable servers.
Updates are applied optimistically locally, so your changes will be reflected in your extension
before the promise resolves.
functiondeleteRecord(record){
if(table.hasPermissionToDeleteRecord(record)){
table.deleteRecordAsync(record);
}
// The record is now deleted within your extension (eg will not be returned
// in `table.selectRecords`) but it is still being saved to Airtable
// servers (e.g. it may not look deleted to other users yet).
}
asyncfunctiondeleteRecordAsync(record){
if(table.hasPermissionToDeleteRecord(record)){
await table.deleteRecordAsync(record);
}
// Record deletion has been saved to Airtable servers.
Throws an error if the user does not have permission to delete the given records.
You may only delete up to 50 records in one call to deleteRecordsAsync.
See Write back to Airtable for
more information about write limits.
This action is asynchronous: await the returned promise if you wish to wait for the
delete to be persisted to Airtable servers.
Updates are applied optimistically locally, so your changes will be reflected in your extension
before the promise resolves.
functiondeleteRecords(records){
if(table.hasPermissionToDeleteRecords(records)){
table.deleteRecordsAsync(records);
}
// The records are now deleted within your extension (eg will not be
// returned in `table.selectRecords()`) but are still being saved to
// Airtable servers (e.g. they may not look deleted to other users yet).
}
asyncfunctiondeleteRecordsAsync(records){
if(table.hasPermissionToDeleteRecords(records)){
await table.deleteRecordsAsync(records);
}
// Record deletions have been saved to Airtable servers.
The field matching the given ID or name. Throws if no matching field exists within this table.
Use getFieldIfExists instead if you are unsure whether a field 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 getFieldById or getFieldByName methods
instead.
Gets the field matching the given ID. Throws if that field does not exist in this table. Use
getFieldByIdIfExists instead if you are unsure whether a field exists with the given
ID.
Gets the field matching the given name. Throws if no field exists with that name in this
table. Use getFieldByNameIfExists instead if you are unsure whether a field exists
with the given name.
Gets the field matching the given name, or null if no field exists with that name in this
table.
const field = myTable.getFieldByNameIfExists('Name');
if(field !==null){
console.log(field.id);
}else{
console.log('No field exists with that name');
}
getFieldIfExists
function(fieldIdOrName:FieldId | string) => Field | null
fieldIdOrName
The ID or name of the field you're looking for.
The field matching the given ID or name. Returns null if no matching field exists within
this table.
This method is convenient when building an extension for a specific base, but for more generic
extensions the best practice is to use the getFieldByIdIfExists or
getFieldByNameIfExists methods instead.
The view matching the given ID or name. Throws if no matching view exists within this table.
Use getViewIfExists instead if you are unsure whether a view 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 getViewById or getViewByName methods
instead.
Gets the view matching the given ID. Throws if that view does not exist in this table. Use
getViewByIdIfExists instead if you are unsure whether a view exists with the given
ID.
Gets the view matching the given name. Throws if no view exists with that name in this table.
Use getViewByNameIfExists instead if you are unsure whether a view exists with the
given name.
The view matching the given ID or name. Returns null if no matching view exists within
this table.
This method is convenient when building an extension for a specific base, but for more generic
extensions the best practice is to use the getViewByIdIfExists or
getViewByNameIfExists methods instead.
Array of objects containing recordId and fields/cellValues to update for that record (specified as an object mapping FieldId or field name to cell value)
An alias for checkPermissionsForUpdateRecords(records).hasPermission.
Checks whether the current user has permission to perform the given record updates.
Accepts partial input, in the same format as updateRecordsAsync.
The more information provided, the more accurate the permissions check will be.
const recordsToUpdate =[
{
// Validating a complete record update
id: record1.id,
fields:{
'Post Title':'How to make: orange-mango pound cake',
'Publication Date':'2020-01-01',
},
},
{
// Like updateRecordsAsync, fields can be specified by name or ID
Consider using useRecords or useRecordIds instead, unless you need the
features of a QueryResult (e.g. queryResult.getRecordById). Record hooks handle
loading/unloading and updating your UI automatically, but manually selecting records is
useful for one-off data processing.
Select and load records from the table. Returns a RecordQueryResult promise where
record data has been loaded.
Consider using useRecords or useRecordIds instead, unless you need the
features of a QueryResult (e.g. queryResult.getRecordById). Record hooks handle
loading/unloading and updating your UI automatically, but manually selecting records is
useful for one-off data processing.
Once you've finished with your query, remember to call queryResult.unloadData().
asyncfunctionlogRecordCountAsync(table){
const query =await table.selectRecordsAsync();
console.log(query.recordIds.length);
query.unloadData();
}
toString
function() => string
A string representation of the model for use in debugging.
cell values to update in that record, specified as object mapping FieldId or field name to value for that field.
Updates cell values for a record.
Throws an error if the user does not have permission to update the given cell values in
the record, or if invalid input is provided (eg. invalid cell values).
This action is asynchronous: await the returned promise if you wish to wait for the updated
cell values to be persisted to Airtable servers.
Updates are applied optimistically locally, so your changes will be reflected in your extension
before the promise resolves.
Array of objects containing recordId and fields/cellValues to update for that record (specified as an object mapping FieldId or field name to cell value)
Updates cell values for records.
Throws an error if the user does not have permission to update the given cell values in
the records, or if invalid input is provided (eg. invalid cell values).
You may only update up to 50 records in one call to updateRecordsAsync.
See Write back to Airtable for more information
about write limits.
This action is asynchronous: await the returned promise if you wish to wait for the
updates to be persisted to Airtable servers.
Updates are applied optimistically locally, so your changes will be reflected in your extension
before the promise resolves.
const recordsToUpdate =[
// Fields can be specified by name or ID
{
id: record1.id,
fields:{
'Post Title':'How to make: orange-mango pound cake',