Improvements
- Smaller core
- Faster by default
- Better
async/await
support
Breaking changes
.value()
doesn't persist database anymore, instead .write()
should be used after you modify the database:
// before
const result = db.get('posts')
.push(post)
.value()
// after
const result = db.get('posts')
.push(post)
.write()
This change makes using async/await
syntax easier:
// before
function create(post) {
const result = db.get('posts')
.push(post)
.value()
return db.write()
.then(() => result)
}
// after
async function create (post) {
const result = await db.get('posts')
.push(post)
.write()
}
Other changes
writeOnChange
is deprecated aswrite
is now explicit.- storages are available under
lib/storages
(example:lowdb/lib/storages/file-async
) .d.ts
file has been removed
Why?
In v0.14.0
, every time .value
was called, JSON.stringify
was run to detect changes. Although this worked for small databases, it wasn't efficient for bigger ones.
Alternatively, it was possible to disable this behaviour using writeOnChange: false
and improve performances but its usage wasn't obvious.
Additionally, it makes clearer when data is written and when not.