Save multiple datas using "setCurrentItemIndex"

Hello all,
i’m having an issue , but cant find solution.
my database have field “Number” named “rates”, my dataset is set to read&write.
what i wanna do is editing my datas in the DB.

// here is the code  : 
let A = 10

$w("#dataset1").setCurrentItemIndex(0).then(() => {$w("#dataset1").setFieldValue("rates", A)
$w("#dataset1").save(); 
})

that is working perfectly, however when i try to add multiple datas it does not complete all

// here is the code :

let A = 10
let B = 20
let C = 30
let D = 40

$w("#dataset1").setCurrentItemIndex(0).then(() => {$w("#dataset1").setFieldValue("rates", A)
$w("#dataset1").setCurrentItemIndex(1).then(() => {$w("#dataset1").setFieldValue("rates", B)
$w("#dataset1").setCurrentItemIndex(2).then(() => {$w("#dataset1").setFieldValue("rates", C)
$w("#dataset1").setCurrentItemIndex(3).then(() => {$w("#dataset1").setFieldValue("rates", D)
$w("#dataset1").save(); 
})})})})

i don’t know what to do to make it work and i don’t wanna do multiple “$w(”#dataset1").save()"
Anyone could help me ?
Thanks in Advance !

i think i don’t have choice, here is what im doing now. its work but its slow…
let A = 10 ; let B = 20; …

$w( "#dataset6" ).setCurrentItemIndex( 0 ).then(() => {$w( "#dataset6" ).setFieldValue( "rates" ,A)}).then(()=>{ 
         $w( "#dataset6" ).setCurrentItemIndex( 1 ).then(() => {$w( "#dataset6" ).setFieldValue( "rates" ,B)}).then(()=>{ 
        $w( "#dataset6" ).setCurrentItemIndex( 2 ).then(() => {$w( "#dataset6" ).setFieldValue( "rates" , C)}).then(()=>{ 
        $w( "#dataset6" ).setCurrentItemIndex( 3 ).then(() => {$w( "#dataset6" ).setFieldValue( "rates" , D)}).then(()=>{ 
        $w( "#dataset6" ).setCurrentItemIndex( 4 ).then(() => {$w( "#dataset6" ).setFieldValue( "rates" , E)}).then(()=>{ 
        $w( "#dataset6" ).setCurrentItemIndex( 5 ).then(() => {$w( "#dataset6" ).setFieldValue( "rates" , F)}).then(()=>{ 
        $w( "#dataset6" ).setCurrentItemIndex( 6 ).then(() => {$w( "#dataset6" ).setFieldValue( "rates" , G)}).then(()=>{ 
        $w( "#dataset6" ).setCurrentItemIndex( 7 ).then(() => {$w( "#dataset6" ).setFieldValue( "rates" , H)}).then(()=>{ 
        $w( "#dataset6" ).setCurrentItemIndex( 8 ).then(() => {$w( "#dataset6" ).setFieldValue( "rates" ,I)}).then(()=>{ 
        $w( "#dataset6" ).setCurrentItemIndex( 9 ).then(() => {$w( "#dataset6" ).setFieldValue( "rates" , J)}).then(()=>{ 
        $w( "#dataset6" ).setCurrentItemIndex( 10 ).then(() => {$w( "#dataset6" ).setFieldValue( "rates" , K)}).then(()=>{ 
        $w( "#dataset6" ).setCurrentItemIndex( 12 ).then(() => {$w( "#dataset6" ).setFieldValue( "rates" , L)}).then(()=>{ 
        $w( "#dataset6" ).setCurrentItemIndex( 13 ).then(() => {$w( "#dataset6" ).setFieldValue( "rates" , M)}).then(()=>{ 
        $w( "#dataset6" ).setCurrentItemIndex( 14 ).then(() => {$w( "#dataset6" ).setFieldValue( "rates" , N)}).then(()=>{ 
        $w( "#dataset6" ).setCurrentItemIndex( 15 ).then(() => {$w( "#dataset6" ).setFieldValue( "rates" , O)}).then(()=>{ 
        $w( "#dataset6" ).setCurrentItemIndex( 16 ).then(() => {$w( "#dataset6" ).setFieldValue( "rates" , Q)}).then(()=>{ 
        $w( "#dataset6" ).setCurrentItemIndex( 17 ).then(() => {$w( "#dataset6" ).setFieldValue( "rates" , R)}).then(()=>{ 
        $w( "#dataset6" ).setCurrentItemIndex( 18 ).then(() => {$w( "#dataset6" ).setFieldValue( "rates" , S)}).then(()=>{ 
        $w( "#dataset6" ).setCurrentItemIndex( 19 ).then(() => {$w( "#dataset6" ).setFieldValue( "rates" , T)}).then(()=>{ 
        $w( "#dataset6" ).setCurrentItemIndex( 20 ).then(() => {$w( "#dataset6" ).setFieldValue( "rates" , U)}).then(()=>{ 
        $w( "#dataset6" ).setCurrentItemIndex( 21 ).then(() => {$w( "#dataset6" ).setFieldValue( "rates" , V)}).then(()=>{$w( "#dataset6" ).save().then(()=>{console.log ( "done ! " )})}) 

}) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) })