Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

139
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!