Skip to content

Commit

Permalink
Merge pull request #3071 from pnp/version-4
Browse files Browse the repository at this point in the history
Release 4.2.0
  • Loading branch information
juliemturner authored Jun 17, 2024
2 parents 61b0e28 + 61df3d1 commit 3fd6088
Show file tree
Hide file tree
Showing 17 changed files with 118 additions and 186 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## 4.2.0 - 2024-June-17

- Only documentation and package updates

## 4.1.1 - 2024-June-05

### Fixed
Expand Down Expand Up @@ -70,6 +74,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

- sp
- getPaged method removed from _Items/IItems
- getAll method removed from _Items/IItems
- PagedItemCollection removed from library
- removed /items/get-all import, unneeded, use async iterator patterns
- ./operations.ts methods moved to ./spqueryable.ts
Expand Down
24 changes: 0 additions & 24 deletions docs/graph/taxonomy.md
Original file line number Diff line number Diff line change
Expand Up @@ -384,27 +384,3 @@ const termInfo = await graph.termStore.sets.getById("338666a8-1111-2222-3333-f72

const termInfo2 = await graph.termStore.groups.getById("338666a8-1111-2222-3333-f72471314e72").sets.getById("338666a8-1111-2222-3333-f72471314e72").getTermById("338666a8-1111-2222-3333-f72471314e72").delete();
```

## Get Term Parent

The server API changed again, resulting in the removal of the "parent" property from ITerm as it is not longer supported as a path property. You now must use "expand" to load a term's parent information. The side affect of this is that the parent is no longer chainable, meaning you need to load a new term instance to work with the parent term. An approach for this is shown below.

```TypeScript
import { graphfi } from "@pnp/graph";
import "@pnp/graph/taxonomy";

const graph = graphfi(...);

// get a ref to the set
const set = graph.termStore.groups.getById("338666a8-1111-2222-3333-f72471314e72").sets.getById("338666a8-1111-2222-3333-f72471314e72");

// get a term's information and expand parent to get the parent info as well
const w = await set.getTermById("338666a8-1111-2222-3333-f72471314e72").expand("parent")();

// get a ref to the parent term
const parent = set.getTermById(w.parent.id);

// make a request for the parent term's info - this data currently match the results in the expand call above, but this
// is to demonstrate how to gain a ref to the parent and select its data
const parentInfo = await parent.select("Id", "Descriptions")();
```
49 changes: 8 additions & 41 deletions docs/sp/items.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ console.log(items2);

### Get Paged Items

Working with paging can be a challenge as it is based on skip tokens and item ids, something that is hard to guess at runtime. To simplify things you can use the Async Iterator functionality on the Items class to assist. For advanced paging techniques using the Async Iterator, please review [Async Paging]('../concepts/async-paging.md')
Working with paging can be a challenge as it is based on skip tokens and item ids, something that is hard to guess at runtime. To simplify things you can use the Async Iterator functionality on the Items class to assist. For advanced paging techniques using the Async Iterator, please review [Async Paging]('/concepts/async-paging.md')

```TypeScript
import { spfi } from "@pnp/sp";
Expand All @@ -41,18 +41,17 @@ import "@pnp/sp/items";

const sp = spfi(...);

// Using async iterator to loop through pages of items in a large list
for await (const items of sp.web.lists.getByTitle("BigList").items()) {
console.log(items);
break; // closes the iterator, returns
}

//using async iterator in combination with top() to get pages of items in chunks of 10
//using async iterator in combination with top() to get pages of items in chunks of up to 5000, if left off returns 100 items per loop.
for await (const items of sp.web.lists.getByTitle("BigList").items.top(10)) {
console.log(items); //array of 10 items
break; // closes the iterator, returns
break; // closes the iterator, returns -- stops retrieving pages
}

// One example of how to type "items"
let items: IMyItem;
for await (items of sp.web.lists.getByTitle("BigList").items()) {
//...process item batch...
}
```

### getListItemChangesSinceToken
Expand All @@ -79,38 +78,6 @@ const changes = await sp.web.lists.getByTitle("BigList").getListItemChangesSince

```

### Get All Items

Using the items collection's getAll method you can get all of the items in a list regardless of the size of the list. Sample usage is shown below. Only the odata operations top, select, and filter are supported. usingCaching and inBatch are ignored - you will need to handle caching the results on your own. This method will write a warning to the Logger and should not frequently be used. Instead the standard paging operations should be used.

> In v3 there is a separate import for get-all to include the functionality. This is to remove the code from bundles for folks who do not need it.
```TypeScript
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);

// use select and top. top will set page size and override the any value passed to getAll
const allItems: any[] = await sp.web.lists.getByTitle("BigList").items.select("Title").top(4000).getAll();
console.log(allItems.length);

// we can also use filter as a supported odata operation, but this will likely fail on large lists
const allItems: any[] = await sp.web.lists.getByTitle("BigList").items.select("Title").filter("Title eq 'Test'").getAll();
console.log(allItems.length);
```

### Retrieving Lookup Fields

When working with lookup fields you need to use the expand operator along with select to get the related fields from the lookup column. This works for both the items collection and item instances.
Expand Down
1 change: 0 additions & 1 deletion docs/sp/tenant-properties.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ This method can be used from any web to retrieve values previously set.

```TypeScript
import { spfi, SPFx } from "@pnp/sp";
import "@pnp/sp/appcatalog";
import "@pnp/sp/webs";
import { IStorageEntity } from "@pnp/sp/webs";

Expand Down
Loading

0 comments on commit 3fd6088

Please sign in to comment.