@@ -16,15 +16,15 @@ async function datasetExample(client) {
1616 console . log ( `Dataset created with ID: ${ dataset . id } ` ) ;
1717
1818 // Add items to the dataset
19- await client . storage . dataset . addItems ( [
19+ await client . storage . dataset . addItems ( dataset . id , [
2020 { name : 'Product 1' , price : 19.99 , category : 'Electronics' } ,
2121 { name : 'Product 2' , price : 29.99 , category : 'Home' } ,
2222 { name : 'Product 3' , price : 9.99 , category : 'Clothing' }
2323 ] ) ;
2424 console . log ( 'Items added to dataset' ) ;
2525
2626 // Get items from the dataset
27- const items = await client . storage . dataset . getItems ( {
27+ const items = await client . storage . dataset . getItems ( dataset . id , {
2828 page : 1 ,
2929 pageSize : 10
3030 } ) ;
@@ -48,7 +48,7 @@ async function kvStorageExample(client) {
4848 console . log ( `KV namespace created with ID: ${ namespace . id } ` ) ;
4949
5050 // Set values in the namespace
51- await client . storage . kv . setValue ( {
51+ await client . storage . kv . setValue ( namespace . id , {
5252 key : 'appConfig' ,
5353 value : JSON . stringify ( {
5454 apiVersion : '1.0' ,
@@ -61,11 +61,11 @@ async function kvStorageExample(client) {
6161 console . log ( 'Value set in KV store' ) ;
6262
6363 // Get value from the namespace
64- const config = await client . storage . kv . getValue ( 'appConfig' ) ;
64+ const config = await client . storage . kv . getValue ( namespace . id , 'appConfig' ) ;
6565 console . log ( 'Retrieved config:' , JSON . parse ( config ) ) ;
6666
6767 // List keys in the namespace
68- const keys = await client . storage . kv . listKeys ( { page : 1 , pageSize : 10 } ) ;
68+ const keys = await client . storage . kv . listKeys ( namespace . id , { page : 1 , pageSize : 10 } ) ;
6969 console . log ( 'KV store keys:' , keys ) ;
7070
7171 console . log ( 'KV storage example completed\n' ) ;
@@ -89,13 +89,13 @@ async function objectStorageExample(client) {
8989 console . log ( `Object bucket created with ID: ${ bucket . id } ` ) ;
9090
9191 // Upload a file to the bucket (in a real scenario, you would use a real file path)
92- const uploadResult = await client . storage . object . put ( {
92+ const uploadResult = await client . storage . object . put ( bucket . id , {
9393 file : 'example/sample-image.jpg'
9494 } ) ;
9595 console . log ( 'File uploaded to object storage:' , uploadResult ) ;
9696
9797 // List objects in the bucket
98- const objects = await client . storage . object . list ( { page : 1 , pageSize : 10 } ) ;
98+ const objects = await client . storage . object . list ( bucket . id , { page : 1 , pageSize : 10 } ) ;
9999 console . log ( 'Objects in bucket:' , objects ) ;
100100
101101 console . log ( 'Object storage example completed\n' ) ;
@@ -119,7 +119,7 @@ async function queueStorageExample(client) {
119119 console . log ( `Queue created with ID: ${ queue . id } ` ) ;
120120
121121 // Push messages to the queue
122- const message1 = await client . storage . queue . push ( {
122+ const message1 = await client . storage . queue . push ( queue . id , {
123123 name : 'processImage' ,
124124 payload : JSON . stringify ( {
125125 imageId : '123' ,
@@ -131,7 +131,7 @@ async function queueStorageExample(client) {
131131 } ) ;
132132 console . log ( 'Message pushed to queue:' , message1 ) ;
133133
134- const message2 = await client . storage . queue . push ( {
134+ const message2 = await client . storage . queue . push ( queue . id , {
135135 name : 'generateReport' ,
136136 payload : JSON . stringify ( { reportType : 'monthly' , format : 'pdf' } ) ,
137137 retry : 2 ,
@@ -141,12 +141,12 @@ async function queueStorageExample(client) {
141141 console . log ( 'Message pushed to queue:' , message2 ) ;
142142
143143 // Pull messages from the queue
144- const messages = await client . storage . queue . pull ( ) ;
144+ const messages = await client . storage . queue . pull ( queue . id ) ;
145145 console . log ( 'Messages pulled from queue:' , messages ) ;
146146
147147 // Acknowledge a message (if any)
148148 if ( messages && messages . length > 0 ) {
149- await client . storage . queue . ack ( messages [ 0 ] . id ) ;
149+ await client . storage . queue . ack ( queue . id , messages [ 0 ] . id ) ;
150150 console . log ( `Message ${ messages [ 0 ] . id } acknowledged` ) ;
151151 }
152152
@@ -169,7 +169,7 @@ async function runExample() {
169169 // Run the examples
170170 await datasetExample ( client ) ;
171171 await kvStorageExample ( client ) ;
172- await objectStorageExample ( client ) ;
172+ // await objectStorageExample(client);
173173 await queueStorageExample ( client ) ;
174174
175175 console . log ( 'All storage examples completed successfully' ) ;
0 commit comments