Giter Club home page Giter Club logo

Comments (6)

jonschlinkert avatar jonschlinkert commented on May 25, 2024 1

you don't need to call .load() for loading data, you should just do store.set(object) or store.set(key, val). That will automatically update the persisted data and in-memory data. If that still doesn't work let us know.

edit: doh! I just realized that I hadn't published version 3.0! I was obviously confused, and I'm sure I confused you guys as well. Apologies!

@plopez01 try again with 3.0 and let me know if you have any issues. thanks!

from data-store.

jonschlinkert avatar jonschlinkert commented on May 25, 2024

Make sure you have the latest version of data-store, and use the API (call .load()) to get the store instead of node's fs methdods. Otherwise you might be trying to load the store before a write has been performed.

Also note that there have been some changes to internals in 2.0. It sounds like you were using private properties, there is no longer a .cache property in 2.0.

edit: @doowb changed to 2.0 (this is published to npm but currently still in the dev branch)

from data-store.

plopez01 avatar plopez01 commented on May 25, 2024

Thanks, im going to update data-store and see if works. Im using gists to download a json and set that download json to the .json file of data-store, my problem was that when i update the json, the "data" doesn't get updated until i restart my app. Let's see if updating helps.

from data-store.

plopez01 avatar plopez01 commented on May 25, 2024

I am calling store.load() and it's not working. Let me show my code.

gists.download({id: 'ID of gist'}, function(err, res) {
  let finalconte = JSON.parse(conte);
  baseDatos = finalconte.files['abc.json'].content
  store.load(baseDatos);
});

This code is not loading the content of the gist to the store, and I don't know why.

from data-store.

doowb avatar doowb commented on May 25, 2024

@plopez01 store.load() re-loads the json file into memory. It doesn't take any arguments.
If you do the following, then it will re-load the store, then update it with the new values:

store.load();
store.set(baseDatos);

If you want to completely overwrite the file with the new data, then you can do this:

// this will overwrite the entire object, then save it to the file.
store.data = baseDatos;

from data-store.

plopez01 avatar plopez01 commented on May 25, 2024

Well thanks a lot!

from data-store.

Related Issues (20)

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.