Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

136
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda