Adds a new table to the specified base's default data source on a NocoDB server via its
POST /api/v2/meta/bases/{id_base}/tables
API endpoint.
To add a new table to a specific (external) data source, use create_data_src_tbl()
instead.
Usage
create_tbl(
name,
cols,
title = NULL,
meta = NULL,
order = NULL,
id_base = base_id(hostname = hostname, email = email, password = password, api_token =
api_token),
hostname = pal::pkg_config_val("hostname"),
email = pal::pkg_config_val("email"),
password = pal::pkg_config_val("password"),
api_token = pal::pkg_config_val("api_token")
)
Arguments
- name
Table name. A character scalar.
- cols
Table columns specification as a list or something coercible to like a data frame.
- title
NocoDB-specific table title. A character scalar.
- meta
NocoDB-specific table metadata. A list.
- order
A number to assign as the table's NocoDB-specific order "weight".
- id_base
NocoDB base identifier as returned by
base_id()
. A character scalar.- hostname
NocoDB server hostname. A character scalar.
E-mail address of the NocoDB user to authenticate with.
- password
Password of the NocoDB user to authenticate with.
- api_token
NocoDB API token. Takes precedence over
email
andpassword
if provided.
Value
A tibble with metadata about the newly created NocoDB table, invisibly.
Details
Besides the specified cols
, NocoDB automatically creates the additional columns
created_at
,
updated_at
,
created_by
and
updated_by
as system fields.
See also
Other functions to manage NocoDB tables:
create_data_src_tbl()
,
data_src_tbls()
,
delete_tbl()
,
reorder_tbl()
,
set_tbl_metadata()
,
tbl
,
tbl_id()
,
tbls()
,
update_tbl()
Examples
if (FALSE) { # \dontrun{
# create new table with a single PK column
nocodb::create_tbl(name = "my_new_table",
title = "MyNewTable",
cols = list(list(column_name = "id",
title = "id",
dt = "text",
dtx = "text",
nrqd = FALSE,
rqd = TRUE,
ck = FALSE,
pk = TRUE,
un = FALSE,
ai = FALSE,
uidt = "LongText")))} # }