Store data in a file synchronously
$ npm install file-store-sync
Simply the module return a constructor that receive as a unique parameter the path to the file to use and just execute the operations that you need. Remember, no callbacks, all the operations are synchronously.
var FileStoreSync = require'file-store-sync';var store = './store-test';
- get(key) - Return the value associated with the key
- set(key, value) - Set or override the value associated with the key
- push(key, value) - Add a value to the array associate with the key
- pushIfNotExists(key, value) - Add a value if it doesn't exist into the array associated with the key
- remove(key, value) - Remove the value from the array associated with the key
- remove(key, value) - Remove the value associated with the key
'use strict';var FileStoreSync = require'file-store-sync';var store = './store-test';storepush'array-key' 'array-value';storepushIfNotExists'array-key' 'array-value';console.log'The value of array-key is: ' + storeget'array-key';storeset'key' some: 'value' ;console.log'The value of key is: ' + storeget'key';storeremove'array-key' 'array-value';console.log'Now array-key is: ' + storeget'array-key';storedelete'key';console.log'Now the value of key is: ' + storeget'key';
I would like to appreciate to Raynos to develop the file-store project and release that under MIT license.
License (The MIT License)
Copyright (c) 2013 Ivan Fraixedes Cugat email@example.com
This project is a fork from the project file-store developed Raynos (https://github.com/Raynos/file-store)
Copyright (c) 2012 Raynos.