Skip to content

Releases: typicode/lowdb

v7.0.0

26 Dec 23:10
Compare
Choose a tag to compare

πŸš€ 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 ❀️

v6.1.1

23 Oct 14:00
Compare
Choose a tag to compare
  • Fix JSONPreset and JSONSyncPreset

v6.1.0

14 Oct 01:00
Compare
Choose a tag to compare

New presets

Before

import { Low } from 'lowdb'
import { JSONFile } from 'lowdb/node'

const adapter = new JSONFile(file)
const defaultData = { posts: [] }
const db = new Low(adapter, defaultData)

await db.read()

Now

import { JSONPreset } from 'lowdb/node'

const defaultData = { posts: [] }
const db = await JSONPreset('db.json', defaultData)

This will also use the Memory adapter automatically when NODE_ENV=test making tests faster.

TypeScript

Lowdb now supports the broader fs.PathLike type which lets you use URL type in addition to string. This is useful for ESM.

// Read from 'db.json' relatively to the current module path using URL
JSONPreset(new URL('db.json', import.meta.url), defaultData)

v6.0.1

28 Apr 09:20
Compare
Choose a tag to compare

What's Changed

  • fix: imported subpaths types correctly by @Krak798 in #569

New Contributors

  • @Krak798 made their first contribution in #569

Full Changelog: v6.0.0...v6.0.1

v6.0.0

19 Apr 01:06
Compare
Choose a tag to compare

What's Changed

  • Drop Node 14 support
  • Require defaultData parameter for Low and LowSync constructors to improve TypeScript experience
  • Move examples from Markdown to real TypeScript files

How to upgrade:

// v5
const defaultData = { posts: [] }
const db = new Low(adapter)
db.data ||= defaultData

function add() {
  db.data.posts.push('title') // TS error
}
// v6
const defaultData = { posts: [] }
const db = new Low(adapter, defaultData)

function add() {
  db.data.posts.push('title') // No TS error
}

If you like lowdb, please sponsor my work. If you cannot, a star or tweet is always appreciated.
Thank you!

v5.1.0

02 Feb 22:15
Compare
Choose a tag to compare

What's Changed

New Contributors

Full Changelog: v5.0.4...v5.1.0

v5.0.0

22 Oct 01:39
Compare
Choose a tag to compare

Better support for front-end tools like Vite, CodeSandbox, ...

To achieve this, Node and Browser (localStorage) adapters are now split in two.
Besides that, there are no other breaking changes.

Node

// Before
import { Low, JSONFile } from 'lowdb'

// After
import { Low } from 'lowdb'
import { JSONFile } from 'lowdb/node'

lowdb/node exports JSONFile, JSONFileSync, TextFile and TextFileSync.

Browser

// Before
import { LowSync, LocalStorage } from 'lowdb'

// After
import { LowSync } from 'lowdb'
import { LocalStorage } from 'lowdb/browser'

lowdb/browser exports LocalStorage.

v4.0.0

17 Oct 23:35
Compare
Choose a tag to compare
  • Drop Node 12 support
  • Update dependencies

v3.0.0

13 Sep 14:36
Compare
Choose a tag to compare
  • Switch license from "Sponsors and OSS Only" to MIT
  • Use native # instead of TypeScript private keyword for adapters
  • Update dependencies
  • No breaking change in terms of code

Many thanks to Mockend and everyone on GitHub Sponsors for supporting this project ❀️ πŸ¦‰

v2.1.0

24 May 11:05
Compare
Choose a tag to compare
  • Add TextFile and TextFileSync adapters to simplify writing to different formats (YAML, XML, ...) and make encryption easier.