Comparing version 0.3.1 to 0.3.2
@@ -110,3 +110,4 @@ (function() { | ||
} | ||
return underdb.save(low.db, path); | ||
underdb.save(low.db, path); | ||
return low; | ||
}; | ||
@@ -120,7 +121,9 @@ | ||
} | ||
return low.db = underdb.load(path); | ||
low.db = underdb.load(path); | ||
return low; | ||
}; | ||
low.on = function(event, listener) { | ||
return ee.on(event, listener); | ||
ee.on(event, listener); | ||
return low; | ||
}; | ||
@@ -127,0 +130,0 @@ |
{ | ||
"name": "lowdb", | ||
"version": "0.3.1", | ||
"version": "0.3.2", | ||
"description": "Flat JSON file database", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
# LowDB [![NPM version](https://badge.fury.io/js/lowdb.svg)](http://badge.fury.io/js/lowdb) [![Build Status](https://travis-ci.org/typicode/lowdb.svg)](https://travis-ci.org/typicode/lowdb) | ||
> Flat JSON file database. | ||
> Flat JSON file database for Node | ||
@@ -14,2 +14,4 @@ * Serverless | ||
_If you need something similar for the browser, check [Underscore.db](https://github.com/typicode/underscore.db)._ | ||
## Usage | ||
@@ -44,3 +46,3 @@ | ||
```javascript | ||
var songs = low('songs', { title: 'low' }) | ||
var songs = low('songs', { title: 'low!' }) | ||
``` | ||
@@ -65,2 +67,4 @@ | ||
_To run the benchmark on your machine, clone the project and run `npm install && npm run benchmark`._ | ||
## API | ||
@@ -75,3 +79,3 @@ | ||
```javascript | ||
var topFiveSongs = low('posts') | ||
var topFiveSongs = low('songs') | ||
.where({published: true}) | ||
@@ -128,3 +132,3 @@ .sortBy('views') | ||
low('songs', id) | ||
// -> low('songs').get(id).value() | ||
// == low('songs').get(id).value() | ||
``` | ||
@@ -134,3 +138,3 @@ | ||
low('songs', {title: 'low!'}) | ||
// -> low('songs').where({title: 'low!'}).value() | ||
// == low('songs').where({title: 'low!'}).value() | ||
``` | ||
@@ -140,3 +144,3 @@ | ||
low('songs', {title: 'low!'}, +1) | ||
// -> low('songs').insert({title: 'low!'}).value() | ||
// == low('songs').insert({title: 'low!'}).value() | ||
``` | ||
@@ -146,3 +150,3 @@ | ||
low('songs', {title: 'low!'}, -1) | ||
// -> low('songs').removeWhere({title: 'low!'}).value() | ||
// == low('songs').removeWhere({title: 'low!'}).value() | ||
``` | ||
@@ -152,3 +156,3 @@ | ||
low('songs', id, -1) | ||
// -> low('songs').remove(id).value() | ||
// == low('songs').remove(id).value() | ||
``` | ||
@@ -158,3 +162,3 @@ | ||
low('songs', id, {title: 'new title'}) | ||
// -> low('songs').update(id, {title: 'new title'}).value() | ||
// == low('songs').update(id, {title: 'new title'}).value() | ||
``` | ||
@@ -164,7 +168,31 @@ | ||
low('songs', {published: false}, {published: true}) | ||
// -> low('songs').updateWhere({published: false}, {published: true}).value() | ||
// == low('songs').updateWhere({published: false}, {published: true}).value() | ||
``` | ||
## Licence | ||
## FAQ | ||
__How is database saved?__ | ||
Database is only saved to disk when you call `insert`, `update`, `updateWhere`, `remove`, `removeWhere`. | ||
Also writing is synchronous but throttled to keep things fast. | ||
Here's an example to illustrate: | ||
```javascript | ||
low('posts').insert({ title: 'foo' }) // database is persisted synchronously | ||
low('posts').insert({ title: 'foo' }) // database is not persisted | ||
low('posts').insert({ title: 'foo' }) // database is not persisted | ||
// 100 ms later database will be persisted synchronously | ||
``` | ||
So in 1 second, LowDB will make, at most, 10 synchronous writes. | ||
_Future versions of LowDB may be fully asynchronous._ | ||
__Does it support concurrency?__ | ||
Yes. Node being single threaded and changes to database being synchronously written, there's no risk of having concurrency problems. | ||
## License | ||
LowDB is released under the MIT License. |
Sorry, the diff of this file is not supported yet
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
16166
161
188