Insert indexeddb data into HTML by insertion order

0

I have a database that stores 3 fields that should be listed in html.

  function gerar_conteudo() {

var transaction = db.transaction('TABELA_CITOLOGIA', "readonly");
var store = transaction.objectStore('TABELA_CITOLOGIA');
var request = store.openCursor();

// Variável que vai pegar todos os objetos do banco.
var output = '';

request.onsuccess = function(event) {

    var cursor = event.target.result;

    if (cursor) {
        // Gera o html da tabela
        output += "<div id='item_tabela_" + cursor.value.id + "'>";
        output += "<div>" + cursor.value.id + "</div>";
        output += "<div>" + cursor.value.nome + "</div>";
        output += "<div>" + cursor.value.email + "</div>";
        output += "<div><a class='botao_remover' href=''onClick='remover(" + cursor.value.id + ");'>deletar</a></div>";
        output += "</div>";

        console.log(cursor.value);
        cursor.continue();
    }

    document.getElementById("lista").innerHTML = output;
}
}

In HTML I have a simple list that shows the results, but they are being added in a cluttered way, instead of being added above the list, the result goes to the end. How can I do so that the result is shown in the order other data is entered? I have already tried with appendChild, insertBefore (I do not know if correctly) and I could not.

    
asked by anonymous 31.03.2018 / 16:26

0 answers