awaitDB.transaction(getData);// 반드시 (await db)를 해야 프라미스가 성공
};
constloadAndQueryDB=async()=>{
try{
console.log('load and db query ....');
awaitpopulateDatabase(awaitdb);
}catch(error){
console.log(error);
}
};
constgetData=()=>{
db.transaction(tx=>{console.log("데이터 가져오기");tx.executeSql('SELECT * FROM Test;',[],(tx,results)=>{console.log("select ");console.log('results:',results.rows.row)},(error)=>console.log(error))})
constgetData=asynctx=>{
console.log('데이터 가져오기');
try{
const[txn,results]=awaittx.executeSql('SELECT * FROM money');
console.log('results: ',results.rows.item(0));
}catch(error){
console.log('error in getData',error);
}
}
constcreateTable=()=>{
db.transaction(tx=>{console.log("테이블 생성하기");tx.executeSql('CREATE TABLE IF NOT EXISTS Test('+'age INTEGER);',[],()=>{console.log("테이블 생성 성공 ");},(error)=>console.log(error))})
constcreateTable=asynctx=>{
console.log('테이블 생성하기');
try{
const[txn,results]=awaittx.executeSql('CREATE TABLE IF NOT EXISTS Test('+'Money INTEGER);');
console.log("테이블 생성 성공 ");
}catch(error){
console.log('error in createTable',error);
}
}
constinsertData=()=>{
db.transaction(tx=>{console.log("데이터 삽입하기");tx.executeSql('INSERT INTO Test (age) VALUES (23);',[],()=>{console.log("삽입 성공");},(error)=>console.log(error))})
constinsertData=async()=>{
try{
(awaitdb).transaction((tx)=>{
console.log("데이터 삽입하기");
tx.executeSql('INSERT INTO assets_type (assets_id, assets_name) VALUES (?,?);',