Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(deps): update dependency lowdb to v6 - autoclosed #192

Closed
wants to merge 1 commit into from

Conversation

svc-secops
Copy link
Contributor

@svc-secops svc-secops commented Dec 6, 2023

This PR contains the following updates:

Package Change Age Adoption Passing Confidence
lowdb ^1.0.0 -> ^6.0.0 age adoption passing confidence

Release Notes

typicode/lowdb (lowdb)

v6.1.1

Compare Source

  • Fix JSONPreset and JSONSyncPreset

v6.1.0

Compare Source

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

Compare Source

What's Changed

New Contributors

Full Changelog: typicode/lowdb@v6.0.0...v6.0.1

v6.0.0

Compare Source

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

Compare Source

What's Changed

New Contributors

Full Changelog: typicode/lowdb@v5.0.4...v5.1.0

v5.0.5

Compare Source

v5.0.3

Compare Source

v5.0.2

Compare Source

v5.0.1

Compare Source

v5.0.0

Compare Source

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.1

Compare Source

v4.0.0

Compare Source

  • Drop Node 12 support
  • Update dependencies

v3.0.0

Compare Source

  • 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

Compare Source

  • Add TextFile and TextFileSync adapters to simplify writing to different formats (YAML, XML, ...) and make encryption easier.

v2.0.3

Compare Source

v2.0.2

Compare Source

v2.0.1

Compare Source

v2.0.0

Compare Source

  • Out of the box and improved TypeScript support.
  • Uses new steno version for fast async file writes.
  • Uses ECMAScript modules.
  • Plain JS can now be used to modify and query db.data
  • Reduced install size.
  • With native JavaScript improvements, lodash is now optional (you can still use it though as it provides powerful utilities).

To help with OSS funding, lowdb v2 is released under Parity license for a limited time. It'll be released under MIT license once the goal of 100 sponsors is reached (currently at 55) or in five months. See README for complete explanation.

You can sponsor me on GitHub Sponsors.

Thank you!

Migrate

Lowdb v1
const low = require('lowdb')
const FileSync = require('lowdb/adapters/FileSync')

const adapter = new FileSync('db.json')
const db = low(adapter)

// Set some defaults
db.defaults({ posts: [], user: {} })
  .write()

// Add a post
db.get('posts')
  .push({ id: 1, title: 'lowdb is awesome'})
  .write()

// Set a user name using Lodash shorthand syntax
db.set('user.name', 'typicode')
  .write()
Lowdb v2
import { Low, FileSync } from 'lowdb'

const adapter = new FileSync('db.json')
const db = new Low(adapter)

// Set some defaults
db.data ||= { posts: [], user: {} })
db.write()

// Add a post
db.data
  .posts
  .push({ id: 1, title: 'lowdb is awesome'})
db.write()

// Set a user name using plain JS
db.data.user.name = 'typicode'
db.write()

If you're using TypeScript, data can now be typed:

type Post = {
  id: number
  title: string
}

type Data = {
  posts: Post[]
}

const db = new Low<Data>(adapter)

To continue using lodash with lowdb:

npm install lodash
import lodash from 'lodash'

// Set a user name using Lodash shorthand syntax
db.chain = lodash.chain(db.data)
db.chain
  .set('user.name', 'typicode')
  .value()
db.write()

Breaking changes

The following methods and properties have been removed:

  • db.getState (use db.data instead)
  • db.setState (use db.data = ... instead)
  • db._

Configuration

📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - "after 8am and before 4pm on tuesday" in timezone Etc/UTC.

🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 Ignore: Close this PR and you won't be reminded about this update again.


This PR has been generated by Renovate Bot.

@svc-secops svc-secops requested a review from a team as a code owner December 6, 2023 12:10
@svc-secops svc-secops force-pushed the renovate/lowdb-6.x branch 2 times, most recently from 17a051e to fb7f407 Compare December 12, 2023 12:30
Copy link

netlify bot commented Dec 12, 2023

Deploy Preview for eclectic-pie-88a2ba canceled.

Name Link
🔨 Latest commit 6b196f5
🔍 Latest deploy log https://app.netlify.com/sites/eclectic-pie-88a2ba/deploys/65843c30e45e53000881caa4

@svc-secops svc-secops force-pushed the renovate/lowdb-6.x branch 4 times, most recently from 9d27d76 to 66fff9e Compare December 19, 2023 12:13
@svc-secops svc-secops changed the title fix(deps): update dependency lowdb to v6 fix(deps): update dependency lowdb to v6 - autoclosed Jan 3, 2024
@svc-secops svc-secops closed this Jan 3, 2024
@svc-secops svc-secops deleted the renovate/lowdb-6.x branch January 3, 2024 12:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant