api_update_object_set: Batch update metadata of objects

View source: R/api_update.R

api_update_object_setR Documentation

Batch update metadata of objects

Description

Batch update metadata of objects

Usage

api_update_object_set(object_ids, updates)

Arguments

object_ids

internal, numeric ids of the objects.

updates

named list with the metadata field(s) to update and the updated value(s). Use api_object() to find their names. Due to a current bug, the list should contain either regular fields only or free fields only, but not a mix of both.

Value

The number of updated objects.

Examples

# get list of possible fields via the `object` endpoint
str(api_object(24473014))

# change one field of metadata in one object
api_update_object_set(24473014, list(longitude=10))
# check that the change is effective
api_object(24473014)$longitude

# change several fields in one object
api_object(24473014)[c("longitude", "latitude")]
api_update_object_set(24473014, list(longitude=0, latitude=0))
api_object(24473014)[c("longitude", "latitude")]

api_object(24473014)$free_columns[c("area", "mean")]
api_update_object_set(24473014, list(area=1, mean=1))
api_object(24473014)$free_columns[c("area", "mean")]

# change several fields in several objects
api_update_object_set(c(24473014, 24473015), list(longitude=5, latitude=-2))
api_object(24473014)[c("longitude", "latitude")]
api_object(24473015)[c("longitude", "latitude")]

# change the taxonomic identification
api_update_object_set(24473014, list(classif_id=1, classif_qual="V"))
api_object(24473014)[c("classif_id", "classif_qual")]

# restore initial values
api_update_object_set(
  c(24473014, 24473015),
  list(longitude=7.31567, latitude=43.68500)
) # NB: these objects were actually collected in the same location
api_update_object_set(24473014, list(classif_id=11509, classif_qual="P"))
api_update_object_set(24473014, list(area=1028, mean=224))
api_update_object_set(24473015, list(area=1118, mean=225))

jiho/ecotaxar documentation built on Jan. 16, 2024, 12:26 a.m.