github typicode/lowdb v0.15.0

latest releases: v7.0.1, v7.0.0, v6.1.1...
7 years ago

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 as write 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.

Don't miss a new lowdb release

NewReleases is sending notifications on new releases.