Socket
Book a DemoInstallSign in
Socket

@chcaa/json-db

Package Overview
Dependencies
Maintainers
2
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@chcaa/json-db

The core module of **json-db** that can be used independently of the **[json-db Editor](https://json-db.chc.au.dk)**.

0.4.0
latest
npmnpm
Version published
Maintainers
2
Created
Source

json-db Core

The core module of json-db that can be used independently of the json-db Editor.

The module supports the following:

  • CLI tools for exporting data and renaming collections and collection properties.
  • Programmatically interaction with a json-db database, supporting the same features as the editor such as creating, editing and searching entries.

CLI Tools

The json-db core module includes a set of CLI tools for exporting data and altering the database schema. All CLI tools can be executed using npx.

Each CLI tool includes a -h / --help command that prints all required and optional arguments and options.

Example

npx @chcaa/json-db@latest json-db export -h

To get a list of all available commands and global options run:

npx @chcaa/json-db@latest json-db -h

Exporting Entries

Export entries from the database in ndjson format with the possibility of searching and populating relational entries.

Example - general usage

npx @chcaa/json-db@latest json-db export "/path/to/db/root-dir" "collectionName" "/dest/path/entries.ndjson" -q "query" -p "populateField1,populateField12"

Example - export "books" with "authors"

npx @chcaa/json-db@latest json-db export "/path/to/books-db books" "/desktop/books.ndjson" -p "authors"

Example - export "books" including files

npx @chcaa/json-db@latest json-db export "/path/to/books-db books" "/desktop/books" -f

Renaming a Collection

Rename a collection and all references to the collection in the database schema.

Example - general usage

npx @chcaa/json-db@latest json-db rename-collection "/path/to/db/root-dir" "currentPluralName" "newPluralName" "newSingularName"

Example - rename the collection "books" to "works"

npx @chcaa/json-db@latest json-db rename-collection "/path/to/books-db" "books" "works" "work"

Renaming a Collection Field

Rename a collection field and all references to the field both in the schema and in entries of the collection.

Example - general usage

npx @chcaa/json-db@latest json-db rename-collection-field "/path/to/db/root-dir" "collectionPluralName" "fieldPath" "newPropName" "newPropTitle"

Example - rename the "author" field in the "books" collection to "writers"

npx @chcaa/json-db@latest json-db rename-collection-field "/path/to/books-db" "books" "authors" "writers" "Writers"

Bulk Updating Entries

Currently, the CLI tools do not support bulk updates on entries such as updating the property of all entries where a specific condition is met.

But jq should is most cases be able to carry out the required task.

Install jq from https://jqlang.org/download/

E.g., to rename the genre of all books where the current genre is "classics" to "must-read" the following jq expression can be used.

jq '.entries |= map(if .genre == "classics" then .genre = "must-read" else . end)' books.json > books-new.json

Verify that the content of the books-new.json is correct and overwrite the current file (mv books-new.json books.json).

Experiment with jq at https://play.jqlang.org/.

FAQs

Package last updated on 29 Aug 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.