Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Store Scheduled Setting better #6

Open
rachelnicole opened this issue Nov 28, 2015 · 4 comments
Open

Store Scheduled Setting better #6

rachelnicole opened this issue Nov 28, 2015 · 4 comments

Comments

@rachelnicole
Copy link
Owner

Maybe localStorage or implement a simple DB system.

@lee-dohm
Copy link
Contributor

It's simple enough to store it in a file unless you really need something more complicated.

@rachelnicole
Copy link
Owner Author

@lee-dohm could you point me to a resource so I can read up on how to do this? I never deal with having to store anything usually / someone else does backend management for me so storing data is new to me. :)

@toddself
Copy link

@rachelnicole you might have a look at level or PouchDB. PouchDB is pretty awesome since you can use it on the front end (using whatever your browser supports) or on the backend (it actually uses level behind the scenes there)

@lee-dohm
Copy link
Contributor

@rachelnicole Sure thing! You're already using the required library on line 3. You can do this:

var fs = require('fs'),
    path = require('path'),
    process = require('process');

// Modify where the file is stored to taste
var configFile = path.join(process.env.HOME, 'feeding-interval.txt');

function retrieveInterval() {
  return fs.readFileSync(configFile);
}

function storeInterval(interval) {
  fs.writeFileSync(configFile, interval);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants