Create many new SB items

Share:

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

1
2
items_create(parent_id = user_id(), title, ..., info = NULL,
  session = current_session())

Arguments

parent_id

An sbitem object or character ScienceBase ID corresponding to the parent item (folder). This must be of length 1 or more. If length 1, then we recycle it for every item.

title

Two or more titles for the new SB items

...

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

info

(optional) list of metadata info for the new items. for each item include a named list of variables

session

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

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
## 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)

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.