Skip to content

Commit f722f4c

Browse files
docs: certified reads and nodejs options (#478)
* docs: certified reads and nodejs options Signed-off-by: David Dal Busco <david.dalbusco@outlook.com> * 📄 Update LLMs.txt snapshot for PR review --------- Signed-off-by: David Dal Busco <david.dalbusco@outlook.com> Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 1e6a3eb commit f722f4c

5 files changed

Lines changed: 190 additions & 0 deletions

File tree

.llms-snapshots/llms-full.txt

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1216,6 +1216,48 @@ The `deleteFilteredDocs` function allows you to delete multiple documents from a
12161216
import { deleteFilteredDocs } from "@junobuild/core";await deleteFilteredDocs({ collection: "my_collection_key", filter: { // Same options as filter of listDocs }});
12171217
```
12181218

1219+
---
1220+
1221+
## Options
1222+
1223+
This section covers additional options that can be used with most of the functions listed above.
1224+
1225+
### Certified Reads
1226+
1227+
All read functions support a `certified` option that can be enabled to guarantee cryptographic verification of the returned data.
1228+
1229+
By default, uncertified reads are used for better performance and UX. Those are faster but do not provide cryptographic guarantees.
1230+
1231+
When `options.certified` is enabled, the function performs an update call under the hood. This ensures the response is verified by the Internet Computer but may increase latency.
1232+
1233+
#### When to Use Certified Reads
1234+
1235+
Certified reads matter when trust in displayed information is more important than speed, or when your app exposes publicly verifiable data — such as user balances, or voting results.
1236+
1237+
For those use cases, a common pattern is deduplicating the call: making an uncertified call for UX purposes — fetching and displaying data quickly — and an update call in parallel, which might take longer but ensures verification. If the latter fails, revert the information and warn users about the issue.
1238+
1239+
#### Example
1240+
1241+
```
1242+
import { listDocs } from "@junobuild/core";await listDocs({ collection: "my_collection_key", options: { certified: true }});
1243+
```
1244+
1245+
### Node.js Usage
1246+
1247+
In Node.js or outside the browser, you must explicitly pass a `satellite` parameter specifying the satellite configuration, so the function knows which satellite to target and how to connect to it.
1248+
1249+
This is required because `initSatellite()` is only available in browser environments.
1250+
1251+
**Important:**
1252+
1253+
You never need to set this parameter in a browser context.
1254+
1255+
#### Example
1256+
1257+
```
1258+
import { getDoc } from "@junobuild/core";await getDoc({ collection: "my_collection_key", key: "my_document_key", satellite: { identity: myIdentity, satelliteId: "aaaaa-bbbbb-ccccc-ddddd-cai", container: true }});
1259+
```
1260+
12191261
# Lifecycle
12201262

12211263
Understand the full journey of Serverless Functions in Juno, from setup and development to deployment and maintenance.
@@ -2191,6 +2233,48 @@ The `deleteFilteredAssets` function allows you to delete multiple assets from a
21912233
import { deleteFilteredAssets } from "@junobuild/core";await deleteFilteredAssets({ collection: "my_collection_key", filter: { // Uses the same filter options as listAssets }});
21922234
```
21932235

2236+
---
2237+
2238+
## Options
2239+
2240+
This section covers additional options that can be used with most of the functions listed above.
2241+
2242+
### Certified Reads
2243+
2244+
All read functions support a `certified` option that can be enabled to guarantee cryptographic verification of the returned data.
2245+
2246+
By default, uncertified reads are used for better performance and UX. Those are faster but do not provide cryptographic guarantees.
2247+
2248+
When `options.certified` is enabled, the function performs an update call under the hood. This ensures the response is verified by the Internet Computer but may increase latency.
2249+
2250+
#### When to Use Certified Reads
2251+
2252+
Certified reads matter when trust in displayed information is more important than speed, or when your app exposes publicly verifiable data — such as user balances, or voting results.
2253+
2254+
For those use cases, a common pattern is deduplicating the call: making an uncertified call for UX purposes — fetching and displaying data quickly — and an update call in parallel, which might take longer but ensures verification. If the latter fails, revert the information and warn users about the issue.
2255+
2256+
#### Example
2257+
2258+
```
2259+
import { listAssets } from "@junobuild/core";await listAssets({ collection: "my_collection_key", options: { certified: true }});
2260+
```
2261+
2262+
### Node.js Usage
2263+
2264+
In Node.js or outside the browser, you must explicitly pass a `satellite` parameter specifying the satellite configuration, so the function knows which satellite to target and how to connect to it.
2265+
2266+
This is required because `initSatellite()` is only available in browser environments.
2267+
2268+
**Important:**
2269+
2270+
You never need to set this parameter in a browser context.
2271+
2272+
#### Example
2273+
2274+
```
2275+
import { getAsset } from "@junobuild/core";await getAsset({ collection: "my_collection_key", fullPath: "/images/logo.png", satellite: { identity: myIdentity, satelliteId: "aaaaa-bbbbb-ccccc-ddddd-cai", container: true }});
2276+
```
2277+
21942278
# Frontend
21952279

21962280
Build full apps with Juno using your preferred frontend framework. These examples cover everything from auth to data handling with React, SvelteKit, Angular, Next.js, and more.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
### Certified Reads
2+
3+
All read functions support a `certified` option that can be enabled to guarantee cryptographic verification of the returned data.
4+
5+
By default, uncertified reads are used for better performance and UX. Those are faster but do not provide cryptographic guarantees.
6+
7+
When `options.certified` is enabled, the function performs an update call under the hood. This ensures the response is verified by the Internet Computer but may increase latency.
8+
9+
#### When to Use Certified Reads
10+
11+
Certified reads matter when trust in displayed information is more important than speed, or when your app exposes publicly verifiable data — such as user balances, or voting results.
12+
13+
For those use cases, a common pattern is deduplicating the call: making an uncertified call for UX purposes — fetching and displaying data quickly — and an update call in parallel, which might take longer but ensures verification. If the latter fails, revert the information and warn users about the issue.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
### Node.js Usage
2+
3+
In Node.js or outside the browser, you must explicitly pass a `satellite` parameter specifying the satellite configuration, so the function knows which satellite to target and how to connect to it.
4+
5+
This is required because `initSatellite()` is only available in browser environments.
6+
7+
:::important
8+
9+
You never need to set this parameter in a browser context.
10+
11+
:::

docs/build/datastore/development.mdx

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,4 +414,45 @@ await deleteFilteredDocs({
414414
});
415415
```
416416

417+
---
418+
419+
## Options
420+
421+
This section covers additional options that can be used with most of the functions listed above.
422+
423+
import CertifiedReads from "../components/certified-reads.md";
424+
425+
<CertifiedReads />
426+
427+
#### Example
428+
429+
```typescript
430+
import { listDocs } from "@junobuild/core";
431+
432+
await listDocs({
433+
collection: "my_collection_key",
434+
options: { certified: true }
435+
});
436+
```
437+
438+
import NodeJSUsage from "../components/nodejs-usage.md";
439+
440+
<NodeJSUsage />
441+
442+
#### Example
443+
444+
```typescript
445+
import { getDoc } from "@junobuild/core";
446+
447+
await getDoc({
448+
collection: "my_collection_key",
449+
key: "my_document_key",
450+
satellite: {
451+
identity: myIdentity,
452+
satelliteId: "aaaaa-bbbbb-ccccc-ddddd-cai",
453+
container: true
454+
}
455+
});
456+
```
457+
417458
[JSON]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#description

docs/build/storage/development.mdx

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,3 +410,44 @@ await deleteFilteredAssets({
410410
}
411411
});
412412
```
413+
414+
---
415+
416+
## Options
417+
418+
This section covers additional options that can be used with most of the functions listed above.
419+
420+
import CertifiedReads from "../components/certified-reads.md";
421+
422+
<CertifiedReads />
423+
424+
#### Example
425+
426+
```typescript
427+
import { listAssets } from "@junobuild/core";
428+
429+
await listAssets({
430+
collection: "my_collection_key",
431+
options: { certified: true }
432+
});
433+
```
434+
435+
import NodeJSUsage from "../components/nodejs-usage.md";
436+
437+
<NodeJSUsage />
438+
439+
#### Example
440+
441+
```typescript
442+
import { getAsset } from "@junobuild/core";
443+
444+
await getAsset({
445+
collection: "my_collection_key",
446+
fullPath: "/images/logo.png",
447+
satellite: {
448+
identity: myIdentity,
449+
satelliteId: "aaaaa-bbbbb-ccccc-ddddd-cai",
450+
container: true
451+
}
452+
});
453+
```

0 commit comments

Comments
 (0)