Storing Data in Electron JS Applications - 4 Methods

Поділитися
Вставка
  • Опубліковано 2 жов 2022
  • Every app requires storing some sort of data. Earlier I made a video about using Sqlite with Electron, in this video I am going to show you 4 other ways of storing data in Electron.
    These methods are suitable for smaller pieces of data that can be stored in key value pairs.
    The methods are
    - Flat JSON file,
    - sessionStorage
    - localStorage
    - IndexedDb
    You can store data in IndexedDb on both the renderer and the main process.
    Watch this video to see these storage methods in detail.
    Code : github.com/cyrilgupta/storing...
    Don't forget to Subscribe and hit the bell icon so that you'll get notified about my videos.
    #electronjs #programming #coding

КОМЕНТАРІ • 25

  • @talhazaryab
    @talhazaryab Рік тому +2

    I wish your channel grow fast. Your content is rare.

  • @ramdomguyfiftychars
    @ramdomguyfiftychars Рік тому +4

    Thank you very much! This helps a ton! Working on a hobby project to play around with Electron+Vite+Vue here :D

  • @tripmad
    @tripmad Рік тому

    Thank u for all your tutorials😊

  • @allencorbalan5879
    @allencorbalan5879 Рік тому

    super informative and helpful thanks!

  • @OmniaAb
    @OmniaAb 3 місяці тому

    very helpful, thank you

  • @arnabshanta
    @arnabshanta Рік тому +1

    Just what I needed

  • @vanbachucnguyen1831
    @vanbachucnguyen1831 2 місяці тому

    thanks for your instruction

  • @dipankarsahoo7119
    @dipankarsahoo7119 Рік тому +1

    this really helped me a lot thanks sir

  • @afnibi
    @afnibi 8 місяців тому

    auto subs...thanks from indonesia

  • @andreicusnir8077
    @andreicusnir8077 Рік тому +1

    Hey I have a question. Would it work with Electron version 23.1.3 and Angular 15? I have tried to save the data with Electron-store from ngx-electron but it failed. I also used IPC to store the data and again, fail. Are there other alternatives? Would be very happy to get an answer. Thanks

  • @adamjones1951
    @adamjones1951 Рік тому

    How do we write multiple data points to the file instead of overwriting the pre-existing data?

  • @arijitchakrabarty1552
    @arijitchakrabarty1552 Рік тому

    Quite insightful! Thanks! Quick question: I have a routine manager application. In it, I want to give the user the ability to store routines. Should I use IndexedDB for that or would storing it in a local json file be better? Thanks!

    • @coderjeet
      @coderjeet  Рік тому +1

      I wouldn't use both. If you have data that needs to be saved, don't save it in browser sessions. Save it in a json file

    • @arijitchakrabarty1552
      @arijitchakrabarty1552 Рік тому

      @@coderjeet understood. Thanks!

  • @senikouame4750
    @senikouame4750 10 місяців тому

    if I use js Fill how can I, make CRUD system with it ??

  • @Dungeon-Umami
    @Dungeon-Umami Рік тому +3

    I did it like this:
    preload.js:
    const {contextBridge, ipcRenderer} = require('electron');
    contextBridge.exposeInMainWorld('storage', {
    w_storage: (data)=>ipcRenderer.invoke('storage', data)
    });
    main_node.js:
    const fs = require("fs");
    ipcMain.handle('storage', (e, result)=>{
    if(result.method === 'read'){
    if (fs.existsSync(result.path)) return JSON.parse(fs.readFileSync(result.path));
    }
    if(result.method === 'write'){
    fs.writeFileSync(result.path, JSON.stringify(result.data, null, 2));
    return "data saved";
    }
    });
    window.js:
    async function herota123(){
    let Need_to_save = {lol: "kek", che: ["bu","rek"]};
    let await_writing = await globalThis.storage.w_storage({method: "write", path: "delete_me.json", data: Need_to_save});
    console.log("await_writing", await_writing);
    let Read_from_memory = await globalThis.storage.w_storage({method: "read", path: "delete_me.json", data: undefined});
    console.log("Read_from_memory", Read_from_memory);
    }
    herota123();

  • @jisonsoft4810
    @jisonsoft4810 4 місяці тому

    Can you create a plugin architecture in electrons?

  • @giriai
    @giriai Рік тому

    But how did you write file on MAS? MAS doesn't allow you to write data to disk...

  • @ABentPaperclip
    @ABentPaperclip Рік тому

    you never actually showed how the json data gets out of an object in main.js back to render- you're just logging it to the console, which isn't enough to re-populate your form...