items_create {sbtools} | R Documentation |
Create many new SB items
Description
A method to create multiple ScienceBase items with a single call and a single HTTP service request. Can be useful for improving performance of creating a large number of items at once.
Usage
items_create(parent_id = user_id(), title, ..., info = NULL)
Arguments
parent_id |
An |
title |
Two or more titles for the new SB items |
... |
Additional parameters are passed on to |
info |
(optional) list of metadata info for the new items. for each item include a named list of variables |
Details
The length of the title
and info
values must be the same
length - however, the parent_id
can be of length 1 or equal to the length
of each of title
and info
parameters
Value
One or more objects of class sbitem
in a list
Examples
## Not run:
# helper function to make a random name
aname <- function() paste0(sample(letters, size = 5, replace = TRUE), collapse = "")
# Create some items - by default we use your user ID
items_create(title = c(aname(), aname()))
# add additional items in the info parameter - by default we use your user ID
items_create(title = c(aname(), aname()),
info = list(
list(contacts = list(list(name = "Suzy"))),
list(contacts = list(list(name = "Brandy")))
)
)
# another example with more information - by default we use your user ID
items_create(title = c(aname(), aname()),
info = list(
list(contacts = list(list(name = "Suzy"))),
list(contacts = list(list(name = "Brandy")))
)
)
# Pass an object of class sbitem
(x <- folder_create(user_id(), aname()))
items_create(x, title = c(aname(), aname()))
## End(Not run)