JavaScript asekron programlama olduğu için Promise yapısını kullandım Tamamını indir

import SQLite from 'react-native-sqlite-storage';

 class Database{

constructor()
{
   
    this.createtable();    
}
createtable()
{

    return new Promise((resolve,reject)=>{
        this.baglan();
        this.baglanti.transaction((tx) => {
            tx.executeSql("select name FROM sqlite_master WHERE type=? AND name=?", ['table','kisiler'],(tx,results)=>{
            
          if(results.rows.item(0)===undefined)
           {     
              tx.executeSql('CREATE TABLE  kisiler(id INTEGER PRIMARY KEY autoincrement NOT NULL, ad text not null,yas integer not null)', []);   
           }
    });    
        });
        this.kapat();
    });
}
success()
{

}
error(err)
{

}
baglan()
{
this.baglanti=SQLite.openDatabase({name: 'kisi.db', location: 'default'},this.success,this.error);       
}
kapat()
{
    return new Promise((resolve,reject)=>{
        this.baglanti=null;
       });    
}
insert(values)
{
   return new Promise((resolve,reject)=>{
    this.baglan();
    this.baglanti.transaction((tx) => {
        tx.executeSql('insert into kisiler (ad,yas) VALUES (?,?)',values);   
      });
   this.kapat();

   });    
}
update(values)
{

    this.baglan();
        this.baglanti.transaction((tx) => {
            tx.executeSql('update kisiler set ad=?,yas=? where id=?',values);
            
          });
       this.kapat(); 

}
delete(values)
{
 return new Promise((resolve,reject)=> 
 {
     this.baglan();
    this.baglanti.transaction((tx) => {
        tx.executeSql('delete from kisiler where id=?',values);
      });
   this.kapat(); 
});

}
get_data()
{
    return new Promise((resolve)=>{

        this.baglan();
        this.baglanti.transaction((tx) => {
            tx.executeSql('select * from kisiler', [], (tx, results) => {
                         
              let array=[];
              for(let i=0;i<results.rows.length;i++)
              {
                array[i]={ad:results.rows.item(i).ad,yas:results.rows.item(i).yas,id:results.rows.item(i).id}
              }
              this.kapat();
            resolve(array);//gönderdiğimizde then ile yakalıyoruz                            
          });
        });
      
    });
}

}
export default Database;