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)
#> ❯ 0 records
#> ⚠ last updated at 2019-04-11 17:29:29

The rtable object therefore does not include any record.

rt$list_records()
#> ❯ Fetching page 1 
#> ✔ 18 records downloaded

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

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)
#> ✔ Sucessfully updated 2 records

We can then return the updated records with.

(updated <- rt$get_updated())
#> # A tibble: 2 x 3
#>   record_id         record_created_time Name            
#>   <chr>             <dttm>              <chr>           
#> 1 reco1vVhXNcWa84Eu 2019-12-04 07:58:56 New Name        
#> 2 recUB9dDHelbylEH1 2019-12-04 07:58:56 Another new name

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()
#> ❯ Fetching page 1 
#> ✔ 20 records downloaded

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

rt$get_listed() %>% 
  nrow()
#> [1] 20