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

185
Visualizações
Middle ground between localStorage and indexedDB for quick and easy access of a complex object?

My current storage system looks like this, because I'm using localStorage:

let storage = {
"SETTING: dataTracking?": false,
"NOTIFICATIONSTATUS: welcome": 'viewed',
"logoClickCount": 0,
"SETTING: soundEffects?": true,
"NOTIFICATIONSTATUS: covid-19": 'viewed'

}

It's super messy and is not intuitive to read when writing code that needs to access the data. For example, I employed the convention of declaring what category an attribute is in by writing "SETTING: foo" or "NOTIFICATIONSTATUS: foo" in order to not have duplicates and keep a clean storage namespace. What I would like to do is this:

let optimalStorage = {
  "logoClickCount": 0,
  "settings": {"dataTracking?":false,"soundEffects?": true},
  "notificationsAlreadySeen": {"welcome":true,"covid-19":false}

}

This would be much better, but localStorage doesn't support that. I wanted to try to try perhaps using indexedDB to simply be able to store this storage object, so that when writing code that needs to pull from the memory I could cleanly do something like

if (optimalStorage['settings']['soundEffects?']) {
   playSound("/music/1.ogg");
}

Ideally, the entire object would not be fetched, only the data value. That way, when I create another branch of storage for several user generated images (data uris), it doesn't need to worry about fetching several megabytes of data each time I want to see if the sound effect option is enabled.

I'm starting to get the feeling that indexedDB is needlessly complex for what I'm trying to accomplish because I haven't been able to understand it at all. Is there a middle ground between localStorage and indexedDB? If not, is there a more simplistic version of indexedDB that just stores one big object for easy and quick access?

about 4 years ago · Juan Pablo Isaza
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