json-fs-store
Advanced tools
Comparing version 0.0.3 to 0.0.4
{ | ||
"name": "json-fs-store", | ||
"description": "File system storage and retrieval of objects as JSON", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"dependencies": { | ||
@@ -6,0 +6,0 @@ "async": "^1.4.2", |
@@ -6,2 +6,8 @@ This Node.js npm module simply serializes JavaScript objects to JSON files into the file system directory of your choosing. | ||
### Installing | ||
``` | ||
npm install json-fs-store | ||
``` | ||
### Creating a store | ||
@@ -32,3 +38,3 @@ | ||
// called when the file has been written | ||
// to the /path/to/storeage/location/12345.json | ||
// to the /path/to/storage/location/12345.json | ||
if (err) throw err; // err if the save failed | ||
@@ -40,9 +46,9 @@ }); | ||
To retrieve an object, you must know its `id` attribute and use it as a parameter for the `load` function. | ||
To retrieve an object, you must know its `id` attribute and use it as a parameter for the `load()` function. | ||
```javascript | ||
store.load('12345', function(err, loaded_donkey){ | ||
store.load('12345', function(err, object){ | ||
if(err) throw err; // err if JSON parsing failed | ||
// do something with loaded_donkey here | ||
// do something with object here | ||
@@ -54,3 +60,3 @@ }); | ||
Every call to the `#list` function reads the file system and returns the objects stored in the directory you specified when you created your store. | ||
Every call to the `list()` function reads the file system and returns the objects stored in the directory you specified when you created your store. | ||
Objects will be sorted according to their `name` attribute, if defined. | ||
@@ -69,3 +75,3 @@ | ||
A stored object may be removed simply by passing the object to the `#remove` function. | ||
A stored object may be removed simply by passing the object to the `remove()` function. | ||
The object's `id` attribute will be used to remove the object's file from the file system. | ||
@@ -72,0 +78,0 @@ |
5678
82