Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

207
Views
How to delete x data sets from YDN Database and do something after that (async)?

I want to delete x rows from a YDN Database and after (!) this is done, do something else.

How can I make the "something else" wait for the delete-loop to finish?

I tried several options like

function DeleteAndThenDoSomethingElse()
{
    return new Promise((resolve, reject) => {

        var df = db.values('myDatabaseTable');
            
        df.done(function (items) {
            var n = items.length;
            var sequence = Promise.resolve();
            for (var i = 0; i < n; i++) 
            {
                const my_i = i;
                const my_premid = items[i].premid;
    
                console.log(i + ': delete Data-ID: '+ my_premid);
                sequence = sequence.then(async function() {
                    await db.remove('datenbank_id', my_premid).done(function() {
                        console.log('Delete of ' + my_premid + ' success.');    
                    }).fail(function(e) {
                        console.log(e.message);
                    });
                });
            }
            sequence = sequence.then(console.log('Now do something else'));
            return sequence;
        }   
    });
}

But the "Now do something else" never waits for the amount of "delete of XY success." I also tried without the async/await-addition. It seems that the db.remove always stays sync.

What do I have to change so that the deletions in the loop are executed first and then something that I chain to the promise after the loop?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!