You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Added Javascript reference to open cloud datastore doc (#916)
## Changes
Adds JavaScript examples to the existing markdown documentation,
providing alternative code implementations alongside the original Python
examples for the user inventory and leaderboard functionalities.
**Update 12.19.24**
Made collapsible sections for JavaScript and Python code. Python code is
open by default since it's the main code on the docs.
## Checks
By submitting your pull request for review, you agree to the following:
- [x] This contribution was created in whole or in part by me, and I
have the right to submit it under the terms of this repository's open
source licenses.
- [x] I understand and agree that this contribution and a record of it
are public, maintained indefinitely, and may be redistributed under the
terms of this repository's open source licenses.
- [x] To the best of my knowledge, all proposed changes are accurate.
---------
Co-authored-by: Jermaine Cheng <[email protected]>
Copy file name to clipboardExpand all lines: content/en-us/cloud/open-cloud/usage-data-stores.md
+204Lines changed: 204 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -78,6 +78,9 @@ When [creating an API Key](./api-keys.md) for this example, make sure you perfor
78
78
79
79
#### Add scripts for the user inventory support portal
80
80
81
+
<detailsopen>
82
+
<summary>Click for Python Example</summary>
83
+
81
84
After creating the API key with permissions required for the example app, you need to add Python scripts to perform app functionalities. The `data_stores_methods.py` file shows how to define [`List Entries`](../../reference/cloud/datastores-api/v1.json#list-entries), [`Get Entry`](../../reference/cloud/datastores-api/v1.json#get-entry), and [`Increment Entry`](../../reference/cloud/datastores-api/v1.json#increment-entry) methods. The `update_inventory` file uses the defined methods to list a subset of user inventories, increase the virtual currency for each user, and update the data.
82
85
83
86
```python title='data_stores_methods.py'
@@ -186,6 +189,102 @@ To test, set the `API_KEY` environment variable and run `update_inventory` file:
186
189
export API_KEY=... \
187
190
python update_inventory
188
191
```
192
+
193
+
</details>
194
+
195
+
<details>
196
+
<summary>Click for JavaScript Example</summary>
197
+
198
+
After creating the API key with the required permissions for the example app, you need to add JavaScript code to perform app functionalities. The `data_stores_methods.js` file shows how to define [`List Entries`](../../reference/cloud/datastores-api/v1.json#list-entries), [`Get Entry`](../../reference/cloud/datastores-api/v1.json#get-entry), and [`Increment Entry`](../../reference/cloud/datastores-api/v1.json#increment-entry) methods. The `update_inventory.js` file uses the defined methods to list a subset of user inventories, increase the virtual currency for each user, and update the data.
console.log(`${updatedObjectKey} now has ${value.robux} robux in their inventory`);
272
+
});
273
+
}
274
+
```
275
+
276
+
To test, set the `API_KEY` environment variable and run the JavaScript file:
277
+
278
+
```bash
279
+
export API_KEY=... \
280
+
node updateInventory.js
281
+
```
282
+
283
+
</details>
284
+
285
+
### External Persistent Leaderboard
286
+
287
+
=======
189
288
190
289
### External persistent leaderboard
191
290
@@ -219,6 +318,9 @@ When [creating an API Key](./api-keys.md) for this example, make sure you perfor
219
318
220
319
#### Add scripts for the leaderboard
221
320
321
+
<detailsopen>
322
+
<summary>Click for Python Example</summary>
323
+
222
324
After creating the API key with permissions required for the example app, you need to add Python scripts to perform app functionalities.
223
325
224
326
The `ordered_data_stores.py` file shows how to define [`List`](../../reference/cloud/datastores-api/ordered-v1.json#list), [`Create`](../../reference/cloud/datastores-api/ordered-v1.json#create), [`Update`](../../reference/cloud/datastores-api/ordered-v1.json#update) and [`Increment`](../../reference/cloud/datastores-api/ordered-v1.json#increment) methods. The `leaderboard` file uses the defined methods to create entries of users in ordered data stores, display scores, increment scores of winning users, and update the leaderboard. The `leaderboard` file also imports a `config` JSON file for configuring the Universe ID, API domain, and your API key.
@@ -308,3 +410,105 @@ python leaderboard
308
410
```
309
411
310
412
After completing testing, you can publish or embed the leaderboard to websites outside of Roblox for more reach.
413
+
414
+
</details>
415
+
416
+
<details>
417
+
<summary>Click for JavaScript Example</summary>
418
+
419
+
After creating the API key with the required permissions for the example app, you need to add JavaScript code to perform app functionalities.
420
+
421
+
The `ordered_data_stores.js` file shows how to define [`List`](../../reference/cloud/datastores-api/ordered-v1.json#list), [`Create`](../../reference/cloud/datastores-api/ordered-v1.json#create), [`Update`](../../reference/cloud/datastores-api/ordered-v1.json#update), and [`Increment`](../../reference/cloud/datastores-api/ordered-v1.json#increment) methods. The `leaderboard.js` file uses the defined methods to create entries of users in ordered data stores, display scores, increment scores of winning users, and update the leaderboard. The `leaderboard.js` file also imports a `config.json` file for configuring the Universe ID, API domain, and your API key.
0 commit comments