Skip to content

Commit ff5ffd4

Browse files
committed
polish
1 parent 06b6cd6 commit ff5ffd4

File tree

4 files changed

+24
-21
lines changed

4 files changed

+24
-21
lines changed
290 KB
Loading
276 KB
Loading

sources/platform/actors/development/actor_definition/key_value_store_schema/index.md

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ await Actor.setValue(`image-${imageID}`, imageBuffer, { contentType: 'image/jpeg
3535
await Actor.exit();
3636
```
3737

38-
To set up the key-value store collections using a single configuration file, use the following template for the `.actor/actor.json` configuration:
38+
To set up the key-value store schema using a single configuration file, use the following template for the `.actor/actor.json` configuration:
3939

4040
```json title=".actor/actor.json"
4141
{
@@ -46,7 +46,6 @@ To set up the key-value store collections using a single configuration file, use
4646
"storages": {
4747
"keyValueStore": {
4848
"actorKeyValueStoreSchemaVersion": 1,
49-
"actorSpecification": 1,
5049
"title": "Key-Value Store Schema",
5150
"collections": {
5251
"documents": {
@@ -70,17 +69,21 @@ The template above defines the configuration for the default key-value store.
7069
Each collection can define its member keys using one of the following properties:
7170

7271
- `keyPrefix` - All keys starting with the specified prefix will be included in the collection (e.g., all keys starting with "document-").
73-
- `key` - A specific individual key that will be included in the collection (e.g., exactly "summary-data").
72+
- `key` - A specific individual key that will be included in the collection.
7473

7574
Note that you must use either `key` or `keyPrefix` for each collection, but not both.
7675

77-
Under the `Storage` tab property of the run or in the key-value store storage detail, there are the tabs for each collection defined in the configuration:
76+
Once the key-value store schema is defined, the tabs for each collection will appear in the `Storage` tab of the Actor's run:
7877

79-
![Storages tab UI](images/kv-store-schema-example.png)
78+
![Storages tab in Run](images/kv-store-schema-example-run.png)
79+
80+
And in the storage detail view too:
81+
82+
![Storage detail](images/kv-store-schema-example-storage.png)
8083

8184
### API Example
8285

83-
You can use the API to list keys from a specific collection by using the `collection` query parameter when calling the [Get list of keys](https://docs.apify.com/api/v2/key-value-store-keys-get) endpoint:
86+
With the key-value store schema defined, you can use the API to list keys from a specific collection by using the `collection` query parameter when calling the [Get list of keys](https://docs.apify.com/api/v2/key-value-store-keys-get) endpoint:
8487

8588
```http title="Get list of keys from a collection"
8689
GET https://api.apify.com/v2/key-value-stores/{storeId}/keys?collection=documents
@@ -141,7 +144,7 @@ You have two choices of how to organize files within the `.actor` folder.
141144
"keyValueStore": {
142145
"actorKeyValueStoreSchemaVersion": 1,
143146
"title": "Key-Value Store Schema",
144-
"collections": {}
147+
"collections": { /* Define your collections here */ }
145148
}
146149
}
147150
}
@@ -165,35 +168,35 @@ You have two choices of how to organize files within the `.actor` folder.
165168
{
166169
"actorKeyValueStoreSchemaVersion": 1,
167170
"title": "Key-Value Store Schema",
168-
"collections": {}
171+
"collections": { /* Define your collections here */ }
169172
}
170173
```
171174

172175
Both of these methods are valid so choose one that suits your needs best.
173176

174177
## Key-value store schema structure definitions
175178

176-
The key-value store schema structure defines the various components and properties that govern the organization and representation of the output data produced by an Actor.
177-
It specifies the structure of the data, the transformations to be applied, and the visual display configurations for the Output tab UI.
179+
The key-value store schema defines the collections of keys (and their properties) in the key-value store.
180+
It allows you to organize and validate data stored by the Actor, making it easier to manage and retrieve specific records.
178181

179182
### Key-value store schema object definition
180183

181184
| Property | Type | Required | Description |
182185
|-----------------------------------|-------------------------------|----------|-----------------------------------------------------------------------------------------------------------------|
183186
| `actorKeyValueStoreSchemaVersion` | integer | true | Specifies the version of key-value store schema structure document. <br/>Currently only version 1 is available. |
184-
| `title` | string | true | - |
185-
| `description` | string | false | - |
186-
| `collections` | Object | true | An object where each key is a collection ID and its value is a collection definition object. |
187+
| `title` | string | true | Title of the schema. Currently not used anywhere. |
188+
| `description` | string | false | Description of the schema. Currently not used anywhere. |
189+
| `collections` | Object | true | An object where each key is a collection ID and its value is a collection definition object (see below). |
187190

188191
### Collection object definition
189192

190-
| Property | Type | Required | Description |
191-
|---------------------------|--------------|----------|-------------------------------------------------------------------------------------------------------------------------------------------------|
192-
| `title` | string | true | The title displayed in the UI in the Output tab <br/>and returned in the API. |
193-
| `description` | string | false | A description of the collection that appears in tooltips in the UI and in API responses. |
194-
| `key` | string | conditional* | Defines a single specific key that will be part of this collection. |
195-
| `keyPrefix` | string | conditional* | Defines a prefix for keys that should be included in this collection. |
196-
| `contentTypes` | string array | false | Allowed content types for records in this collection. Used for validation when storing data. |
197-
| `jsonSchema` | object | false | For collections with content type `application/json`, you can define a JSON schema to validate structure. <br/>Uses JsonSchema Draft 07 format. |
193+
| Property | Type | Required | Description |
194+
|----------------|--------------|--------------|-------------------------------------------------------------------------------------------------------------------------------------------------|
195+
| `title` | string | true | The collection’s title is shown in the storage tab of a run and in the storage detail view, where it appears as a tab for filtering records. |
196+
| `description` | string | false | A description of the collection that appears in tooltips in the UI. |
197+
| `key` | string | conditional* | Defines a single specific key that will be part of this collection. |
198+
| `keyPrefix` | string | conditional* | Defines a prefix for keys that should be included in this collection. |
199+
| `contentTypes` | string array | false | Allowed content types for records in this collection. Used for validation when storing data. |
200+
| `jsonSchema` | object | false | For collections with content type `application/json`, you can define a JSON schema to validate structure. <br/>Uses JsonSchema Draft 07 format. |
198201

199202
\* Either `key` or `keyPrefix` must be specified for each collection, but not both.

0 commit comments

Comments
 (0)