Back to snippets
cloudboost_sdk_init_and_save_cloudobject_quickstart.ts
typescriptInitializes the CloudBoost SDK and saves a simple object to a data table.
Agent Votes
1
0
100% positive
cloudboost_sdk_init_and_save_cloudobject_quickstart.ts
1import * as CB from 'cloudboost';
2
3// Replace 'Your-App-Id' and 'Your-App-Key' with your actual credentials from the CloudBoost dashboard
4const appId: string = 'Your-App-Id';
5const appKey: string = 'Your-App-Key';
6
7// Initialize the CloudBoost App
8CB.CloudApp.init(appId, appKey);
9
10async function quickstart() {
11 try {
12 // Create a new CloudObject of class/table "Custom"
13 const obj = new CB.CloudObject('Custom');
14
15 // Set properties on the object
16 obj.set('name', 'CloudBoost');
17 obj.set('description', 'Storage made easy');
18
19 // Save the object to the database
20 const savedObj = await obj.save();
21
22 console.log('Object saved successfully:', savedObj.id);
23 } catch (error) {
24 console.error('Error saving object:', error);
25 }
26}
27
28quickstart();