Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

140
Vistas
using electron-store with ip as key

Hy,

i try to use electron-store to persist values by ip as key. Using the code:

store.set('users.' + ip, 'foo')

So i want to achieve following object:

{users: [{"192.186.0.0": "foo"},{"192.186.0.1": "bar"}]}

but what i got is

"192": { "168": { "192": { "151": "Foo", "134": "Bar",.....

So is there a way to use ips?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

So what you want is essentially an array of objects, where the objects key is the ip address. In this case though I would rather recommend using an array of arrays because it makes working with the data a bit easier.

So first we create a new Map, which holds our users ip and name:

let map=new Map();
map.set('192.186.0.0', 'foo');
map.set('192.186.0.1', 'bar');

To store this Map using electron-store, we need to pack it into an array and populate the users key.

store.set('users', Array.from(map.entries(map)));

If we want to read out or modify values from the users key, we need to convert the array back to a map.

Let's look at an example - we want to modify 192.186.0.0 to say title instead of foo:

let map=new Map(store.get('users'));
map.set('192.186.0.0', 'title');
store.set('users', Array.from(map.entries(map)));
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda