2
Well I’m cluttering up with these commands, in fact what I’m wanting to do is the following. Using localStorage
maintain a database.
NOME TABELA | DADOS TABELA
tbl_TESTE | {teste 01, teste02, teste03, ...}
tbl_TESTE02 | {arroz, feijão, batata, ...}
**Sendo que todos os dados da tabela é um array de OBJETOS.
When I start the application I set the banks as null I do so:
localStorage.setItem("tbl_TABELA01", []);
localStorage.setItem("tbl_TABELA02", []);
localStorage.setItem("tbl_TAVELA03", []);
This is done only once to not reset the data already entered.
After inserting I do as follows:
var nome = $("#lblNome").val(),
telefone = $("#lblTelefone").val();
var dados = [];
dados.lbNome = nome;
dados.lbTelefone = telefone;
console.log(dados);
//var result = JSON.stringify(dados);
// console.log(result);
var tbl_CELULAS = localStorage.getItem("tbl_CELULAS");
console.log(tbl_CELULAS);
// var parsetbl_CELULAS = JSON.parse(tbl_CELULAS);
// console.log(parsetbl_CELULAS);
tbl_CELULAS.push(dados);
console.log(tbl_CELULAS);
//var JSON = JSON.stringify(tbl_CELULAS);
console.log(JSON);
This is a mess because I do not know how to assemble logic to solve the problem. What I need is before I insert, to search for what I already have in localStorage, thus inserting in last position what I just looked for, then last save again in localStorage.
if you need to maintain a structure similar to a table, it is not better to use the
IndexedDB
?– Tobias Mesquita
@Tobymosque I use, however the indexedDB is giving me problem with portability in old Androids, and the solution to not have more headache is this
– Renan Rodrigues
knows the
Storage.js
, it promises a unique interface toDOM Storage
,WebSQL
andIndexedDB
. you can tell us what technology you will use, if you don’t, it will try to use theIndexedDB
, then theWebSQL
, finally thelocalStorage
.– Tobias Mesquita
@Tobymosque But how would you use tables ?
– Renan Rodrigues
storage(function (context) { context.set("nome entidade", { id: 2, desc: "desc" }, function () { context.get("nome entidade", 1, function(value) { console.log (value.desc) })})})
– Tobias Mesquita