Releases: typicode/lowdb
v0.4.0
New features
Version 0.4.0 is a complete rewrite of the project in order to achieve:
- Better fault tolerancy
- Writing is now atomic. Even if your process crashes, you won't have half written corrupted JSON files.
- Better asynchronism
- Writing is now fully asynchronous.
- Better flexibility
- Custom functions and third-party libraries can now be added using
low.mixin()
. - Underscore.db dependency was removed, LowDB is now pure Lo-Dash. Underscore.db can still be added though using
low.mixin()
.
- Custom functions and third-party libraries can now be added using
- Better API
- Database is now automatically loaded when calling
low(filename)
- Database is now automatically loaded when calling
- Multiple database support
- You can work with multiple JSON files.
Breaking changes
During the process, some compromises needed to be made. Here's the list of the breaking changes:
- API
v0.3.x
var low = require('lowdb').load() // loads db.json (by default)
var posts = low('posts').sortBy('title').value()
v0.4.0
var low = require('lowdb')
var db = low('db.json') // loads db.json (must be explicit)
var posts = db('posts').sortBy('title').value()
- Events
Removed to simplify code. You can use Watch.js to monitor database object or similar projects.
Also Object.observe()
will be available in Node 0.12, so it's just a matter of time before you can have database object events back.
- options
Removed. Use low()
instead.
var db = low() // same as autoSave: false
var db = low('db.json') // same as autoSave: true and path: 'db.json'
- short syntax
Removed. Short syntax was mainly an experiment. If you need it back, please create an issue.
- Underscore.db methods
Underscore.db dependency was removed. You can use Lo-Dash methods to query or manipulate data like push()
, where()
, ... instead of insert()
, get()
, ...
Or you can use mixin()
to add Underscore.db back .
See README for informations about how to extend LowDB.