Coder Social home page Coder Social logo

cocycles / electron-storage Goto Github PK

View Code? Open in Web Editor NEW
128.0 10.0 12.0 22 KB

Simply save/load json files to/from file system in electron applications

License: MIT License

JavaScript 100.00%
electron storage fs file-system node userdata electron-storage

electron-storage's People

Contributors

davej avatar ran-y avatar ranyitz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

electron-storage's Issues

default filePath on macosx?

Hi, where is file created on MacOSX if no path is specified?

I am searching it after i set() it but i can't actually find it....

thanks

storage.get

I have the following code.
` var filePath = "Settings.json"

    storage.set(filePath, "{'balance': 1000.21, 'num':100, 'is_vip':true, 'name':'foo'}")
        .then(data => {
            console.log(data);
        })
        .catch(err => {
            console.error(err);
        });

    storage.get(filePath, (err, data) => {
        if (err) {
            console.error(err)
        } else {
            console.log(data);
        }
    });`

The data is written to the Settings.json under C:\Users\thardes2\AppData\Roaming\MyApp, but when I try to get them with the get function I get the following error:

The file in path C:\Users\thardes2\AppData\Roaming\MyApp/Settings.json is not a valid json file

So the format of the path is wrong. As you can see, I am just using the example provided in the README.
Any idea or solution to this?

Thank you :-)

Question: why are filePaths joined to "userData" folder

why are filePaths joined to "userData" folder?
is it possible to avoid this and save, or load a file from, for example, the user's Desktop? or a custom-defined path relative to the filesystem root?

return path.join(userData, filePath);

Thanks!

Not a Valid JSON file when suing get method.

Hi there. I get this error on macOS.

var data = new Object();
    data.name = name;
    data.address = address;

    storage.set('customers.json', data)
    .then(() => {
      console.log('Data saved successfully!')
    })
    .catch((err) => {
      console.log(err);
    });

It writes to the file but then when I use the get function,

var oldData = storage.get('customers.json')
    .then(d => {
      console.log(d);
    })
    .catch(err => {
      console.log(err);
    });

It gives me that the error.

And here is what the console gives:

Error: The file in path /Users/syncster31/Library/Application Support/ASMS/customers.json is not a valid json file
at /Users/syncster31/Documents/Programming/Electron/my-app/node_modules/electron-storage/dist/index…:37
at tryToString (fs.js:449)
at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:436)

isPathExists doesn't append .json on path

I noticed when trying to use isPathExists, it requires adding the .json to the path name unlike the set and get methods. I'm assuming that's on purpose but it doesn't seem consistent with the other methods.

Maybe that should be clarified in the README?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.