Creates the specified table column on a NocoDB server via its
POST /api/v2/meta/tables/{id_tbl}/columns
API endpoint.
Usage
create_tbl_col(
id_tbl,
column_name,
title = column_name,
uidt = NULL,
colOptions = NULL,
dt = NULL,
cdf = NULL,
rqd = NULL,
pk = NULL,
ai = NULL,
au = NULL,
un = NULL,
enable_rich_text = NULL,
origin = funky::config_val("origin"),
email = funky::config_val("email"),
password = funky::config_val("password"),
api_token = funky::config_val("api_token")
)
Arguments
- id_tbl
character(1)
NocoDB table identifier as returned bytbl_id()
.- column_name
character(1)
Column name.- title
character(1)
NocoDB column title.- uidt
character(1)
NocoDB user interface data type. EitherNULL
for the column's currentuidt
value or one of"AI"
"Attachment"
"AutoNumber"
"Barcode"
"Button"
"Checkbox"
"Collaborator"
"Count"
"CreatedBy"
"CreatedTime"
"Currency"
"Date"
"DateTime"
"Decimal"
"Duration"
"Email"
"ForeignKey"
"Formula"
"GeoData"
"Geometry"
"ID"
"JSON"
"LastModifiedBy"
"LastModifiedTime"
"Links"
"LinkToAnotherRecord"
"LongText"
"Lookup"
"MultiSelect"
"Number"
"Order"
"Percent"
"PhoneNumber"
"QrCode"
"Rating"
"Rollup"
"SingleLineText"
"SingleSelect"
"SpecificDBType"
"Time"
"URL"
"User"
"Year"
.
- colOptions
list()
NocoDB column options. To specify the values for a single-select field (uidt = "SingleSelect"
), supply a data frame with the columnstitle
,color
(HEX color code) andindex
(counted from 0 upwards) as a list element namedoptions
. Defaults to the column's currentcolOptions
value ifNULL
.- dt
character(1)
Column data type. Omitted ifNULL
.- cdf
character(1)
Column default value. Defaults to the column's currentcdf
value ifNULL
. Setcdf = NA
to remove an existingcdf
value.- rqd
logical(1)
Whether or not the column is required to be filled, i.e. should have aNOT NULL
constraint. Corresponds to theNN
advanced field attribute. Defaults to the column's currentrqd
value ifNULL
.- pk
logical(1)
Whether or not the column is a primary key, should have aPRIMARY KEY
constraint. Corresponds to thePK
advanced field attribute. Defaults to the column's currentpk
value ifNULL
.- ai
logical(1)
Whether or not to auto-increment the column value on new record insertion. Corresponds to theAI
advanced field attribute. Defaults to the column's currentai
value ifNULL
.- au
logical(1)
Whether or not to auto-update the column value to the current timestamp on record creation/insertion. Corresponds to theAU
advanced field attribute. Defaults to the column's currentau
value ifNULL
.- un
logical(1)
Whether or not the column is an unsigned number, i.e. can only store non-negative numbers. Corresponds to theUN
advanced field attribute. Defaults to the column's currentun
value ifNULL
.- enable_rich_text
logical(1)
Whether or not to enable rich text support for the column in NocoDB. Only applicable ifuidt = "LongText"
. Omitted ifNULL
.- origin
character(1)
NocoDB server origin.character(1)
E-mail address of the NocoDB user to authenticate with.- password
character(1)
Password of the NocoDB user to authenticate with.- api_token
character(1)
NocoDB API token. Takes precedence overemail
andpassword
if provided.
Value
A tibble with metadata about the newly created NocoDB table column, invisibly.
See also
Other functions to manage NocoDB table columns:
delete_tbl_col()
,
set_display_val()
,
set_display_vals()
,
tbl_col()
,
tbl_col_id()
,
tbl_cols()
,
update_tbl_col()