Skip to content

v7.0.0

Latest
Compare
Choose a tag to compare
@typicode typicode released this 26 Dec 23:10
· 4 commits to main since this release

πŸš€ Simplified syntax with db.update, new adapter for more file format, consistent presets, automatic write error retry, and a TS error fix!

What's New

  • Simplified Syntax: Introducing db.update for easier updates and writes.
  • Flexible Adapters: Added DataFile adapters for supporting various formats like YAML , JSON5, ... and adding features like encryption with minimal code.
  • Automatic Retry: Resolves write errors, especially for Windows users.

Breaking Changes

  • Node 16 Dropped: discontinued support for Node 16.
  • Consistent Naming: Renamed presets for consistency:
    • JSONPreset to JSONFilePreset
    • JSONSyncPreset to JSONFileSyncPreset.

Code Examples

If you were using the JSONPreset, please rename it

- import { JSONPreset } from 'lowdb/node'
+ import { JSONFilePreset } from 'lowdb/node'

Enjoy the simplified syntax with db.update

- db.data.posts.push(newPost)
- await db.write()
+ await db.update(({ posts }) => posts.push(newPost))

Easily support other formats:

const yamlAdapter = new DataFile('db.yaml', {
  parse: YAML.parse,
  stringify: YAML.stringify
})
const db = new Low(yamlAdapter, { posts: [] })

Sponsors

Special thanks to lowdb's current sponsor: Mockend.

Your support is essential, you can sponsor this project on GitHub Sponsors ❀️