π 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.updatefor easier updates and writes. - Flexible Adapters: Added
DataFileadapters for supporting various formats likeYAML,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:
JSONPresettoJSONFilePresetJSONSyncPresettoJSONFileSyncPreset.
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 β€οΈ