简体   繁体   English

如何使用@pnp/pnpjs 库从 SharePoint 在线列表中获取超过 5000 个项目?

[英]How to fetch more than 5000 item from SharePoint Online list using @pnp/pnpjs library?

I am using SharePoint Online.我正在使用 SharePoint 在线。 I am using "@pnp/pnpjs" library to get data from the SharePoint Online list.我正在使用“@pnp/pnpjs”库从 SharePoint 在线列表中获取数据。

I have created a SharePoint list that contains more than 5000 items.我创建了一个包含 5000 多个项目的 SharePoint 列表。

How can I get all list items using the get function from @pnp/pnpjs library?如何使用 @pnp/pnpjs 库中的 get function 获取所有列表项?

How can I filter items based on the condition while getting data from the SharePoint online list using @pnp/pnpjs library?在使用@pnp/pnpjs 库从 SharePoint 在线列表获取数据时,如何根据条件过滤项目?

Thanks谢谢

Using the items collection's getAll method you can get all of the items in a list regardless of the size of the list.使用项目集合的 getAll 方法,您可以获得列表中的所有项目,而不管列表的大小。 Sample usage is shown below.示例用法如下所示。 Only the odata operations top, select, and filter are supported.仅支持odata操作top、select、filter。 usingCaching and inBatch are ignored - you will need to handle caching the results on your own. usingCaching 和 inBatch 将被忽略 - 您将需要自己处理缓存结果。 This method will write a warning to the Logger and should not frequently be used.此方法将向 Logger 写入警告,不应经常使用。 Instead the standard paging operations should be used.相反,应该使用标准的分页操作。

import { spfi } from "@pnp/sp";
import "@pnp/sp/webs";
import "@pnp/sp/lists";
import "@pnp/sp/items";
import "@pnp/sp/items/get-all";

const sp = spfi(...);

// basic usage
const allItems: any[] = await sp.web.lists.getByTitle("BigList").items.getAll();
console.log(allItems.length);

// set page size
const allItems: any[] = await sp.web.lists.getByTitle("BigList").items.getAll(4000);
console.log(allItems.length);

Source: https://pnp.github.io/pnpjs/sp/items/#get-all-items来源: https://pnp.github.io/pnpjs/sp/items/#get-all-items

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用 pnp powershell 获取 SharePoint 在线列表中最后修改项目的项目 ID? - How to get item ID of the last modified item in the SharePoint online list using pnp powershell? 使用 PnPJS 在 SharePoint 列表项上破坏角色 inheritance 时出错 - Error breaking role inheritance on SharePoint list item using PnPJS 如果记录超过5000条,如何查看/编辑Sharepoint列表中的数据? - How to view/edit data in Sharepoint List if there are more than 5000 records? SharePoint 在线 - SPFx - 如何在 PnPjs 中使用 GroupBy - SharePoint Online - SPFx - How to use GroupBy in PnPjs 使用 PnP 获取 SharePoint Online 的用户角色和权限 - Fetch user roles and permissions for SharePoint Online using PnP SharePoint REST API 用于 Sharepoint 在线检索超过 5000 个项目的列表/文档库中的项目 - SharePoint REST API for Sharepoint online retrieving items from a list/document library which exceeds 5000 items 文件夹超过5000个文档时如何查询sharepoint在线数据 - How to query sharepoint online data when folder is having more than 5000 documents 使用 pnp 更新 SharePoint 在线文档库列属性 PowerShell - update SharePoint online document library column property using pnp PowerShell 使用 PoweShell PnP 更新 SharePoint Online 列表中的查找列 - Updating a lookup column in SharePoint Online list using PoweShell PnP 如何使用@pnp/sp 单个 API 调用向 SharePoint 在线列表添加多个字段? - How to add multiple fields to SharePoint Online list using @pnp/sp single API call?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM