update item doc to mention fields

This commit is contained in:
Hong Ooi 2021-05-04 00:43:41 +10:00
Родитель dbf2ddfdb6
Коммит 53a46c9ea0
5 изменённых файлов: 18 добавлений и 11 удалений

Просмотреть файл

@ -30,11 +30,11 @@
#' - `filter`: A string giving an [OData expression](https://docs.microsoft.com/en-us/graph/query-parameters#filter-parameter) to filter the rows to return. Note that column names used in the expression must be prefixed with `fields/` to distinguish them from item metadata.
#' - `n`: The maximum number of (filtered) results to return. If this is NULL, the `ms_graph_pager` iterator object is returned instead to allow manual iteration over the results.
#' - `select`: A string containing comma-separated column names to include in the returned data frame. If not supplied, includes all columns.
#' - `all_metadata`: If TRUE, the returned data frame will contain extended metadata as separate columns, while the data fields will be in a nested data frame named `fields`.
#' - `as_data_frame`: If FALSE, return the result as a list of individual `ms_list_item` objects, rather than a data frame. The `all_metadata` argument is ignored if `as_data_frame=FALSE`.
#' - `all_metadata`: If TRUE, the returned data frame will contain extended metadata as separate columns, while the data fields will be in a nested data frame named `fields`. This is always set to FALSE if `n=NULL` or `as_data_frame=FALSE`.
#' - `as_data_frame`: If FALSE, return the result as a list of individual `ms_list_item` objects, rather than a data frame.
#' - `pagesize`: The number of results to return for each call to the REST endpoint. You can try reducing this argument below the default of 5000 if you are experiencing timeouts.
#'
#' For more information, see [Use query parameters](https://docs.microsoft.com/en-us/graph/query-parameters?view=graph-rest-1.0) at the Graph API reference.
#' Note that the Graph API currently doesn't support retrieving item attachments.
#'
#' @seealso
#' [`get_sharepoint_site`], [`ms_site`], [`ms_list_item`]
@ -111,7 +111,7 @@ public=list(
get_item=function(id)
{
res <- self$do_operation(file.path("items", id))
res <- self$do_operation(file.path("items", id), options=list(expand="fields"))
ms_list_item$new(self$token, self$tenant, res,
site_id=self$properties$parentReference$siteId,
list_id=self$properties$id)

Просмотреть файл

@ -7,13 +7,13 @@
#' - `token`: The token used to authenticate with the Graph host.
#' - `tenant`: The Azure Active Directory tenant for the parent drive.
#' - `type`: always "drive item" for a drive item object.
#' - `properties`: The item properties (metadata).
#' - `properties`: The item properties (data and metadata). This is a list; the item data can be found in the `fields` component.
#' @section Methods:
#' - `new(...)`: Initialize a new object. Do not call this directly; see 'Initialization' below.
#' - `delete(confirm=TRUE)`: Delete this item. By default, ask for confirmation first.
#' - `update(...)`: Update the item's properties (metadata) in Microsoft Graph. To update the list _data_, update the `fields` property. See the examples below.
#' - `do_operation(...)`: Carry out an arbitrary operation on the item.
#' - `sync_fields()`: Synchronise the R object with the item metadata in Microsoft Graph.
#' - `sync_fields()`: Synchronise the R object with the item data and metadata in Microsoft Graph.
#'
#' @section Initialization:
#' Creating new objects of this class should be done via the `get_item` method of the [`ms_list`] class. Calling the `new()` method for this class only constructs the R object; it does not call the Microsoft Graph API to retrieve or create the actual item.
@ -36,6 +36,9 @@
#'
#' item$update(fields=list(firstname="Mary"))
#'
#' # item data (plus some metadata mixed in)
#' item$properties$fields
#'
#' item$delete()
#'
#' }

Просмотреть файл

@ -50,12 +50,12 @@ Creating new objects of this class should be done via the \code{get_list} method
\item \code{filter}: A string giving an \href{https://docs.microsoft.com/en-us/graph/query-parameters#filter-parameter}{OData expression} to filter the rows to return. Note that column names used in the expression must be prefixed with \verb{fields/} to distinguish them from item metadata.
\item \code{n}: The maximum number of (filtered) results to return. If this is NULL, the \code{ms_graph_pager} iterator object is returned instead to allow manual iteration over the results.
\item \code{select}: A string containing comma-separated column names to include in the returned data frame. If not supplied, includes all columns.
\item \code{all_metadata}: If TRUE, the returned data frame will contain extended metadata as separate columns, while the data fields will be in a nested data frame named \code{fields}.
\item \code{as_data_frame}: If FALSE, return the result as a list of individual \code{ms_list_item} objects, rather than a data frame. The \code{all_metadata} argument is ignored if \code{as_data_frame=FALSE}.
\item \code{all_metadata}: If TRUE, the returned data frame will contain extended metadata as separate columns, while the data fields will be in a nested data frame named \code{fields}. This is always set to FALSE if \code{n=NULL} or \code{as_data_frame=FALSE}.
\item \code{as_data_frame}: If FALSE, return the result as a list of individual \code{ms_list_item} objects, rather than a data frame.
\item \code{pagesize}: The number of results to return for each call to the REST endpoint. You can try reducing this argument below the default of 5000 if you are experiencing timeouts.
}
For more information, see \href{https://docs.microsoft.com/en-us/graph/query-parameters?view=graph-rest-1.0}{Use query parameters} at the Graph API reference.
Note that the Graph API currently doesn't support retrieving item attachments.
}
\examples{

Просмотреть файл

@ -16,7 +16,7 @@ Class representing an item in a SharePoint list.
\item \code{token}: The token used to authenticate with the Graph host.
\item \code{tenant}: The Azure Active Directory tenant for the parent drive.
\item \code{type}: always "drive item" for a drive item object.
\item \code{properties}: The item properties (metadata).
\item \code{properties}: The item properties (data and metadata). This is a list; the item data can be found in the \code{fields} component.
}
}
@ -27,7 +27,7 @@ Class representing an item in a SharePoint list.
\item \code{delete(confirm=TRUE)}: Delete this item. By default, ask for confirmation first.
\item \code{update(...)}: Update the item's properties (metadata) in Microsoft Graph. To update the list \emph{data}, update the \code{fields} property. See the examples below.
\item \code{do_operation(...)}: Carry out an arbitrary operation on the item.
\item \code{sync_fields()}: Synchronise the R object with the item metadata in Microsoft Graph.
\item \code{sync_fields()}: Synchronise the R object with the item data and metadata in Microsoft Graph.
}
}
@ -48,6 +48,9 @@ item <- lst_items[[1]]
item$update(fields=list(firstname="Mary"))
# item data (plus some metadata mixed in)
item$properties$fields
item$delete()
}

Просмотреть файл

@ -112,6 +112,7 @@ test_that("SharePoint methods work",
item_id <- items3[[1]]$properties$id
item <- lst$get_item(item_id)
expect_is(item, "ms_list_item")
expect_false(is_empty(item$properties$fields))
newtitle <- make_name(10)
newitem <- lst$create_item(Title=newtitle)