knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

This document covers the RC (reference class) of rtable.

Setup

Create your rtable with the new method, the method works in a fashion similar to setup from the classic API.

Here we set up the session for the demo "Employee Onboarding" base and its "Onboarding Checklist" table. Note that by default the initialisation pulls the records from the table with list_records. This can be turned off by setting the list_records to FALSE when initialising the object, as we demonstrate below.

library(rtable)

rt <- rtable$new(base = "appfSQILnns4mrSUr", table = "Onboarding Checklist", api_key = "xxXXxxxXXX", list_records = FALSE)
library(rtable)

rt <- rtable$new(base = "appfSQILnns4mrSUr", table = "Onboarding Checklist", list_records = FALSE)
rt

The rtable object therefore does not include any record.

rt$list_records()

This is particularly useful if you want to pass specific parameters to list_records and do not want the whole table returned.

Get

If you want to extract the records you can do so with.

rt$get_listed() %>% 
  dplyr::glimpse()

Create

new_records <- dplyr::tibble(Name = c("Something", "Some other thing"))
rt$create_records(new_records)

You can then fetch the created records with.

(created <- rt$get_created())

Update

Now we can update the records we created.

update_records <- dplyr::tibble(
  record_id = created$record_id, 
  Name = c("New Name", "Another new name")
)
rt$update_records(update_records, record_id)

We can then return the updated records with.

(updated <- rt$get_updated())

Important Note that at this point the records we initally pulled using the list_records method have not been updated, only the remote Airtable was. We can can do so with.

rt$refresh()

We see that it pulled 20 records as opposed to the 18 previously fetched because we created two new records.

rt$get_listed() %>% 
  nrow()

Delete

Finally, we can delete those two records we created and updated.

rt$delete_records(created, record_id)


JohnCoene/rtable documentation built on May 8, 2019, 7:37 a.m.