Comparing version 0.2.4 to 0.2.5
@@ -150,3 +150,3 @@ // Generated by CoffeeScript 1.8.0 | ||
save = function(id, o, cb) { | ||
var backup, data, done, file; | ||
var backup, data, done, file, k; | ||
if (typeof id === "object") { | ||
@@ -162,2 +162,9 @@ cb = o; | ||
o = clone(o); | ||
if (this._saveId) { | ||
if ((typeof (k = this._saveId)) === 'string' && k.length > 0) { | ||
o[k] = id; | ||
} else { | ||
o.id = id; | ||
} | ||
} | ||
data = this._single ? (backup = this._cache[id], this._cache[id] = o, this._cache) : o; | ||
@@ -311,2 +318,3 @@ done = (function(_this) { | ||
this._memory = opt.memory === true || opt.type === 'memory'; | ||
this._saveId = opt.saveId; | ||
if (isJSONFile(this.name)) { | ||
@@ -313,0 +321,0 @@ this.name = this.name.split(".json")[0]; |
{ | ||
"name": "jfs", | ||
"version": "0.2.4", | ||
"version": "0.2.5", | ||
"main": "./lib/Store", | ||
@@ -22,6 +22,6 @@ "description": "A simple JSON file store", | ||
"coffee-script": "~1.8.0", | ||
"coffeelint": "~1.7.1", | ||
"coffeelint": "~1.8.1", | ||
"coveralls": "~2.11.2", | ||
"istanbul": "~0.3.5", | ||
"mocha": "~2.0.1" | ||
"mocha": "~2.1.0" | ||
}, | ||
@@ -42,5 +42,5 @@ "repository": { | ||
"prepublish": "coffee -o lib/ -c src/*.coffee", | ||
"test": "./node_modules/.bin/mocha --reporter spec --compilers coffee:coffee-script/register spec/*.spec.coffee", | ||
"test": "npm run lint && ./node_modules/.bin/mocha --reporter spec --compilers coffee:coffee-script/register spec/*.spec.coffee", | ||
"coveralls": "istanbul cover ./node_modules/.bin/_mocha --report lcovonly && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js" | ||
} | ||
} |
@@ -5,5 +5,6 @@ # JSON file store | ||
[![Build Status](https://secure.travis-ci.org/flosse/json-file-store.png)](http://travis-ci.org/flosse/json-file-store) | ||
[![Dependency Status](https://gemnasium.com/flosse/json-file-store.png)](https://gemnasium.com/flosse/json-file-store) | ||
[![NPM version](https://badge.fury.io/js/jfs.png)](http://badge.fury.io/js/jfs) | ||
[![Build Status](https://secure.travis-ci.org/flosse/json-file-store.svg?branch=master)](http://travis-ci.org/flosse/json-file-store) | ||
[![Dependency Status](https://gemnasium.com/flosse/json-file-store.svg)](https://gemnasium.com/flosse/json-file-store) | ||
[![NPM version](https://badge.fury.io/js/jfs.svg)](http://badge.fury.io/js/jfs) | ||
[![License](https://img.shields.io/npm/l/jfs.svg)](https://github.com/flosse/json-file-store/blob/master/LICENCE.txt) | ||
@@ -100,2 +101,13 @@ WARNING: | ||
### ID storage | ||
By default the ID is not stored within your object. | ||
If you like, you can change that behavior by setting `saveId` to `true` | ||
or a custom ID | ||
```javascript | ||
var db = new Store("data",{saveId:'myKey'}); | ||
``` | ||
## Tests | ||
@@ -102,0 +114,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16206
4
418
118