Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

135
Visualizações
cordova-sqlite-storage synchronous two selects - JavaScript

I have a question about Cordova and the Cordova-Sqlite-Storage Plugin.

I want to select two tables, but the second selection is in the loop of the first. But it is not synchronized.

The code isn't productive or anything, it's purposely easy to understand.

document.addEventListener('deviceready', function(){
    var rooms_id_arr = [];
    
    db.transaction(function(tx){
        tx.executeSql('SELECT id FROM rooms', [], function(tx, result_rooms){
            for(var r = 0; r < result_rooms.rows.length; r++){
                rooms_id_arr.push(result_rooms.rows.item(r).id);
            }
        }, function(tx, error) {
            alert("ERROR A: " + error.message);
        });
        for(var r = 0; r < rooms_id_arr.length; r++){
            tx.executeSql('SELECT id FROM regal WHERE roomid=?' , [rooms_id_arr[r]], function(tx, result_regal){
                for(var rg = 0; rg < result_regal.rows.length; rg++){
                    alert("Room: " + r + " Regal: " + rg);
                }
            }, function(tx, error) {
                alert("ERROR B: " + error.message);
            });
        }
    });
});

First Table (rooms): id, name

Secound Table (regal): id, roomid (key from table rooms), name

Every room have more shelves. i know how joins work, i would like to know how to do it that way (for understand). How could this best be implemented? i have tried many options, but have not come to any result. Thank you very much for your answer.

about 4 years ago · Santiago Gelvez
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda