Skip to content

Commit 980ba6d

Browse files
committed
Add upgrade guide
1 parent 4dad6ad commit 980ba6d

File tree

2 files changed

+44
-1
lines changed

2 files changed

+44
-1
lines changed

mint.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
"encrypt-data",
7272
"react",
7373
"faq",
74+
"upgrading",
7475
"how-it-works",
7576
"known-issues",
7677
"indexers",
@@ -117,4 +118,4 @@
117118
"apiHost": "https://a.polybase.xyz"
118119
}
119120
}
120-
}
121+
}

upgrading.mdx

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
---
2+
title: "Upgrading to v0.6.0"
3+
---
4+
5+
For a full list of changes, please refer to the [CHANGELOG](https://polybase.xyz/changelog).
6+
7+
## Record not found, no longer errors
8+
9+
The Polybase client `@polybase/client` no longer throws an error if a record is not found. Polybase now always returns a CollectionRecordResponse.
10+
11+
If the record does not exist, the `.data` property will be `null`. You can call also use the helper method `.exists()` to check if the record exists.
12+
13+
### Before
14+
15+
You had to capture the error and check if it was a `PolybaseError` and if the reason was `record/not-found`.
16+
17+
```js
18+
const userData = await polybase.collection<User>('User').record(publicKey).get()
19+
.catch(async (err) => {
20+
// Previously, you would get an error if the record did not exist
21+
if (err && err instanceof PolybaseError && err.reason === 'record/not-found') {
22+
// Record does not exist
23+
return null
24+
}
25+
throw err
26+
})
27+
```
28+
29+
### After
30+
31+
Polybase client will not error on record not found. Instead, `.data` property will be null.
32+
33+
```js
34+
// userData will always return a CollectionRecordResponse (even if record does not exist)
35+
const userData = await polybase.collection<User>('User').record(publicKey).get()
36+
37+
// Check if the record exists
38+
const exists = userData.exists()
39+
40+
// Or check if the data is null
41+
const exists = userData.data === null
42+
```

0 commit comments

Comments
 (0)