JavaScript - Como realizar consultas en IndexedDB

 
Vista:
sin imagen de perfil

Como realizar consultas en IndexedDB

Publicado por Amaru (3 intervenciones) el 25/05/2015 20:35:43
Quisiera saber consultar los objetos de un almacén con respecto a un id para después poder insertarlo en el HTML,
el código de la base de datos es:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
database = indexedDB.open("DB", 1);
    database.onupgradeneeded = function (e){
        var active = database.result ;
        var store1 = active.createObjectStore("Questions", {keyPath : 'id', autoincrement : true});
        var store = active.createObjectStore("Replyes", {keyPath : 'id', autoincrement : true});
    };
 
    var trans = active.transaction (["Questions"], "readwrite");
    var store = trans.objectStore ("Questions");
    var question = document.getElementById("question").getElementsByTagName("td");
    var reply = document.getElementById("reply").getElementsByTagName("td");
    for (i=0; i<question.length; i++){
        var requestQuestion = store.put({ id : i , Question: question[i].innerHTML, Reply: reply[i].innerHTML});
    };
En SQL seria algo tipo;
SELECT * FROM  Questions WHERE id = x;

devolviendo el valor de 'Question' y 'Reply' dependiendo del valor de x
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder