[英]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.