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
Copy file name to clipboardExpand all lines: content/en-us/cloud/open-cloud/usage-data-stores.md
+192Lines changed: 192 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -78,6 +78,8 @@ When [creating an API Key](./api-keys.md) for this example, make sure you perfor
78
78
79
79
#### Adding Scripts for the User Inventory Support Portal
80
80
81
+
##### > Python Example
82
+
81
83
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
84
83
85
```python title='data_stores_methods.py'
@@ -187,6 +189,93 @@ export API_KEY=... \
187
189
python update_inventory
188
190
```
189
191
192
+
##### > JavaScript Example
193
+
194
+
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`);
268
+
});
269
+
}
270
+
```
271
+
272
+
To test, set the `API_KEY` environment variable and run the JavaScript file:
273
+
274
+
```bash
275
+
export API_KEY=... \
276
+
node updateInventory.js
277
+
```
278
+
190
279
### External Persistent Leaderboard
191
280
192
281
This section walks through a concrete example of creating an external persistent leaderboard in Python, in which you can list and read your users information stored in ordered data stores, make edits, and then publish to an external website for promotion.
@@ -219,6 +308,8 @@ When [creating an API Key](./api-keys.md) for this example, make sure you perfor
219
308
220
309
#### Adding Scripts for the Leaderboard
221
310
311
+
##### > Python Example
312
+
222
313
After creating the API key with permissions required for the example app, you need to add Python scripts to perform app functionalities.
223
314
224
315
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 +399,104 @@ python leaderboard
308
399
```
309
400
310
401
After completing testing, you can publish or embed the leaderboard to websites outside of Roblox for more reach.
402
+
403
+
##### > JavaScript Example
404
+
405
+
After creating the API key with the required permissions for the example app, you need to add JavaScript code to perform app functionalities.
406
+
407
+
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