Skip to content

Commit e165526

Browse files
docs: sdk reference set_doc_store (#372)
Signed-off-by: David Dal Busco <david.dalbusco@outlook.com>
1 parent 7ae6bd8 commit e165526

3 files changed

Lines changed: 96 additions & 2 deletions

File tree

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# SDK
2+
3+
The following functions are provided to help you work with document and asset data inside your Satellite. They are part of the tools available when writing serverless functions in Rust and support common tasks such as interacting with the datastore, storage, and custom hook logic.
4+
5+
:::note[📦 Crate]
6+
7+
The SDK is provided by the [junobuild-satellite](https://docs.rs/junobuild-satellite/latest/junobuild_satellite/index.html) crate.
8+
9+
To use them, add this to your Cargo.toml:
10+
11+
```toml
12+
[dependencies]
13+
junobuild-satellite = "*"
14+
```
15+
16+
You have to follow the pace of the Juno release to ensure compatibility. Refer to the [maintenance guide](../../../build/functions/development/rust.mdx#maintenance) for instructions.
17+
18+
:::
19+
20+
---
21+
22+
## set_doc_store
23+
24+
Sets a document in a collection’s of the datastore. Use this to insert or update document data.
25+
26+
```rust
27+
pub fn set_doc_store(
28+
caller: UserId,
29+
collection: CollectionKey,
30+
key: Key,
31+
value: SetDoc,
32+
) -> Result<DocContext<DocUpsert>, String>
33+
```
34+
35+
📦 See full definition on [docs.rs](https://docs.rs/junobuild-satellite/latest/junobuild_satellite/fn.set_doc_store.html)
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# SDK
2+
3+
The following functions are provided to help you work with document and asset data inside your Satellite. They are part of the tools available when writing serverless functions in Rust and support common tasks such as interacting with the datastore, storage, and custom hook logic.
4+
5+
:::note[📦 Library]
6+
7+
The SDK is provided by the [@junobuild/functions](https://www.npmjs.com/package/@junobuild/functions) library.
8+
9+
To add it to your project:
10+
11+
import { Bash } from "../../../components/bash.mdx";
12+
13+
<Bash
14+
npm="npm i @junobuild/functions"
15+
yarn="yarn add @junobuild/functions"
16+
pnpm="pnpm add @junobuild/functions"
17+
/>
18+
19+
You have to follow the pace of the Juno release to ensure compatibility. Refer to the [maintenance guide](../../../build/functions/development/typescript.mdx#maintenance) for instructions.
20+
21+
:::
22+
23+
---
24+
25+
## setDocStore
26+
27+
Sets a document in a collection’s of the datastore. Use this to insert or update document data.
28+
29+
```typescript
30+
function setDocStore(params: SetDocStoreParams): void;
31+
```
32+
33+
📦 Import from `@junobuild/functions/sdk`
34+
35+
Parameters:
36+
37+
- `params`: An object containing the following fields:
38+
- `caller`: The caller initiating the operation (`RawUserId` or `UserId`).
39+
- `collection`: The name of the collection where the document will be stored.
40+
- `key`: The key identifying the document.
41+
- `doc`: The document content including:
42+
- `data`: A Uint8Array produced by encodeDocData.
43+
- `description` (optional): A short description linked with the document.
44+
- `version` (optional if new): An expected version number to prevent overwrite.
45+
46+
Returns:
47+
48+
- `void`
49+
50+
Throws:
51+
52+
- `ZodError` if the input schema is invalid.
53+
- `Error` if the operation is rejected by the Satellite (e.g. due to a failed assertion or validation error).

sidebars.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,10 @@ const sidebars: SidebarsConfig = {
216216
description:
217217
"API reference for writing serverless functions in Rust."
218218
},
219-
items: ["reference/functions/rust/utils"]
219+
items: [
220+
"reference/functions/rust/sdk",
221+
"reference/functions/rust/utils"
222+
]
220223
},
221224
{
222225
type: "category",
@@ -227,7 +230,10 @@ const sidebars: SidebarsConfig = {
227230
description:
228231
"API reference for writing serverless functions with TypeScript."
229232
},
230-
items: ["reference/functions/typescript/utils"]
233+
items: [
234+
"reference/functions/typescript/sdk",
235+
"reference/functions/typescript/utils"
236+
]
231237
}
232238
]
233239
}

0 commit comments

Comments
 (0)