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

120
Visualizações
How do I add items instead of setting with the web extension storage api?

I am trying to make a recent system where, when you go to an id of an item it stores when u went to that id, something along the lines of this:

chrome.storage.local.set({
[variable of id]: {
 recentTime: new Date(),
 anotherVariable: "hello world"
}});

The problem is that i want to store 2 instances of history, so I want to add another one like this, this is where the problem appears, the previous keys are gone, since it's a set(), not an add()

chrome.storage.local.set({
[variable of id]: {
 recentTime2: new Date(),
 anotherVariable2: "hello world"
}});

however I can fix this by using chrome.storage.local.get() and doing Object.assign() with both variables when setting, this is a bit of a hassle and isn't very efficient but it's fine, I can deal with it.

but what if, I need to do in objects, something with a longer path like this:

chrome.storage.local.set({
something: {
 // there is a variable here in the storage
 something: {
  // there is a variable here in the storage again
  something: "a"
 }
}
});

And like this it becomes a big hassle, and becomes something hard to deal with. I could potentially do a function that can do this automatically but that is very hard for me.

Is there any other efficient way to do this?

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