'React Native SQLLite execute function before going on

I need the lasted Insert ID for the upcomming foreign Key beacuse i'm importing lists. It always executes the for loop first so i made an Manually Insertion for the last id and it should go on when the Actual ID can be inserted but how can i solve this problem?

Insert.js

 export const actualRennenID = () =>{
    return true;
 };
 export const rennenhinzufuegen = (datum, name) =>{
  var rennenID = 0;
  var db = SQLite.openDatabase('skirennen.db', '1.0', 'Alle Rennen der Skilehrer', 200000, openCB, errorCB);
  db.transaction( (tx) => {
   /* tx.executeSql('DROP TABLE gruppen',
    [],
    (tx, results) => { */
    tx.executeSql('INSERT INTO rennen (rennName, datum) VALUES (?,?);', 
    [name, datum],
    (tx, results) => {
      this.iDRennen = results.insertId;
      actualRennenID();
      console.log('rennen Hinzugefuegt mit ID ' + iDRennen); 
  });
  
});
return this.iDRennen;
}

Main.js

 var iDRennen = rennenhinzufuegen(date, nameRennen);
        
  var rennListeEInfuegenAusgefuehrt = false;
  rennListeEInfuegenAusgefuehrt = actualRennenID();
  console.log('Before IF');
  if(rennListeEInfuegenAusgefuehrt == 13){
     for(var c =0; c< reihen.length; c++){... 
nextInsertStatment(iDRennen);
}}

Is there a way, the insert database function run first?

Thanks!

`



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source