items_upsert: Upsert many SB items

View source: R/items_upsert.R

items_upsertR Documentation

Upsert many SB items

Description

Either creates or updates (if items already exist)

Usage

items_upsert(
  parent_id = user_id(),
  title = NULL,
  ...,
  info = NULL,
  session = current_session()
)

Arguments

parent_id

An sbitem object or character ScienceBase ID corresponding to the parent item (folder)

title

The title of the new SB item

...

Additional parameters are passed on to GET, POST, HEAD, PUT, or DELETE

info

(optional) list of metadata info for the new item

session

Session object from authenticate_sb. Defaults to anonymous or last authenticated session

Value

An object of class sbitem

Examples

## Not run: 
# helper function to make a random name
aname <- function() paste0(sample(letters, size = 5, replace = TRUE), collapse = "")

# Create some item - by default we use your user ID
z1 <- item_create(title = aname())
z2 <- item_create(title = aname())

# Upsert items
(x <- items_upsert(list(z1, z2), title = c(aname(), aname())))

# Call item_upsert again, updates this time
items_upsert(x, info = list(
		contacts = list(list(name = "Suzy"))
	)
)

## End(Not run)

sbtools documentation built on May 1, 2023, 1:07 a.m.