You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
List resource methods such as Object.all(), Vault.all() and others currently do not have any built-in pagination support. The following snippet shows how it can be done. Combining lists of data frames requires flattening them first (similar to how we currently paginate dataset query results). Nested keys are flattened (i.e. i[user][email] becomes i[user.email]). Maybe there is a way around this...
require("solvebio")
solvebio::login()
# Retrieves objects within a specific vault.
paginateObjects <- function(vault_id, env = solvebio:::.solveEnv, ...) {
# Retrieve the first page of results
params <- list(...)
params$vault_id <- vault_id
params$env <- env
params$page <- 1
response <- do.call(Object.all, params)
# Flatten the results in order to merge them
# NOTE: This will flatten nested keys with dot-separated paths.
# For example: i$user$email will be i$user.email
objects <- jsonlite::flatten(response$data)
# Retrieve and merge subsequent pages of results
while (!is.null(response$links[['next']])) {
params$page <- params$page + 1
response <- do.call(Object.all, params)
objects <- dplyr::bind_rows(objects, jsonlite::flatten(response$data))
}
return(objects)
}
vault <- Vault.get_personal_vault()
df <- paginateObjects(vault_id=vault$id, object_type="dataset")
print(df$full_path)
The text was updated successfully, but these errors were encountered:
List resource methods such as
Object.all()
,Vault.all()
and others currently do not have any built-in pagination support. The following snippet shows how it can be done. Combining lists of data frames requires flattening them first (similar to how we currently paginate dataset query results). Nested keys are flattened (i.e.i[user][email]
becomesi[user.email]
). Maybe there is a way around this...The text was updated successfully, but these errors were encountered: