npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@sidekick-coder/db

v0.7.0

Published

Cli Tool to manipulate data from diferent sources

Readme

db

A simple tool to manage your data
npm

[!DANGER] The project is in alpha phase, please don't use in production

Installation

npm install -g @sidekick-coder/db

Usage

Create db.config.yml

name: tasks
provider:
  name: file
  config:
    format: markdown
    path: ./tasks-folder # path to the folder with markdown files
db list --where "status=done" # list 

db find --where "id=01" # find single item

db create --data "title=New task&status=todo&body=This is a new task" # create new item

db update --data "status=done" --where "id=01" # update item

db destroy --where "id=01" # delete item

Providers

Database

A database in the context of this lib refers to any data that can be converted to an array of objects.

Examples can be:

  • list of plain text files with key value pairs
  • list of markdown file with frontmatter
  • list of json files
  • list of folders
  • list of rows from a SQL Table (Postgres, MySQL, etc)
  • etc...

Config file

The config file is a yaml file that defines the one or more databases definitions.

The cli will always look for a the db.config.yml file in the current directory, unless you pass a different path as a flag.

db -f "path/to/config.yml"

Single Database config sample

name: tasks
provider:
    name: file
    config:
        path: data
        format: markdown
        id_strategy: increment
view:
    default: default
    sources:
        dirs: views
        files: [./views/default.yml]
        items:
            - name: archived
              where:
                  archived: false

Multiple Databases config sample

databases:
    default: tasks
    sources:
        files: ["content/tasks/db.config.yml"]
        patterns: ["content/*/db.config.yml"]
        items:
            - name: tags
              provider:
                  name: file
                  config:
                      path: ./content/tags/data

            - name: code-snippets
              provider:
                  name: file
                  config:
                      path: content/code-snippets/data

Select the databse with the --database flag

db list --database tags

# or short version 

db list --db tags

List

List items in the database

Options

| Option | Type | Required | Description | | --- | --- | --- | --- | | where | object | false | Where statments to filter data see filters | | limit | number | false | Limit the number of items if provider supports | | page | number | false | Page number if provider supports number pagination | | cursor | string | false | Cursor to start from if provider supports cursor pagination | | include | array | false | Include properties | | exclude | array | false | Exclude properties | | sort-by | string | false | Sort by property | | sort-desc | boolean | false | Sort descending |

Examples

db list
db list --where "status=done"

Find

Find a single item in the database

Options

| Option | Type | Required | Description | | --- | --- | --- | --- | | where | object | false | Where statments to filter data see filters | | include | array | false | Include properties | | exclude | array | false | Exclude properties |

Examples

db find
db find --where "status=done"

Create

Create a new item in the database

Options

| Option | Type | Required | Description | | --- | --- | --- | --- | | data | object | true | Data to be updated |

Examples

db create --data "title=New task&status=todo&body=This is a new task"
db create --data "new-task.yml"
db create --data '{"title": "New task", "status": "todo", "body": "This is a new task"}'

Update

Update an item in the database

Options

| Option | Type | Required | Description | | --- | --- | --- | --- | | data | object | true | Data to be updated | | where | object | false | Where statments to filter data see filters |

[!WARNING] if where is not provided, all items will be updated

Examples

db update --data "status=done" --where "id=01"
db update --data "update-task.yml" --where "id=01"
db update --data '{"status": "done"}' --where "id=01"

Destroy

Delete an item in the database

Options

| Option | Type | Required | Description | | --- | --- | --- | --- | | where | object | false | Where statments to filter data see filters |

[!WARNING] if where is not provided, all items will be deleted

Examples

db destroy --where "id=01"
db destroy --where "delete-task.yml"
db destroy --where '{"id": "01"}'

Variables

Some cli flags accept a special format that can help use complex data structures, similar to ansible variables.

key value

simple key value pairs.

db list --where "path=data" 

load from file

You can load the value from a file by adding the extension to the value

Accepted formats are yml, yaml, json

db list --where "query.yml" 

json

You can pass a json string directly

db list --where '{"path": "data"}'

Views

Views are predefined options to filter, sort and format data

# only query filter in query
include: [id, title, status]

# exclude properties
exclude: [body]

# sort by
sort-by: id
sort-desc: true

# where statments
where: 
    status: done

render: console # render to use
render_options:
    columns:
        - label: ID
          value: id
          width: 3 # 3% terminal width

        - label: Status
          value: status
          width: 10 # 10% terminal width

        - label: Project
          value: project
          width: 10 # 10% terminal width

        - label: Title
          value: title
          # auto width, fill the rest of the terminal width
# load by name
db list --view "done-tasks"

# load by file
db list --view "done-tasks.yml"

Programatic usage

You can use the library in your own javascripts projects too!

Install

npm install @sidekick-coder/db

createDatabase

import { createDatabase } from '@sidekick-coder/db/database'

const definition = {
    name: 'tasks',
    provider: {
        name: 'file',
        config: {
            path: 'data', // absolute path 
            format: 'markdown', 
            id_strategy: 'increment' 
        }
    },
}

const options = {
    root: 'C:\\Users' // optional, root path to resolve relative paths
}

const db = createDatabase(definition, options)

const items = await db.list()

console.log(items)

// also access provider custom methods 
const files = await db.provider.findMetadata()

console.log(files)

createDatabaseFromConfig

import { resolve } from '@sidekick-coder/db/config'
import { createDatabaseFromConfig } from '@sidekick-coder/db/database'

const config = resolve('path/to/db.config.yml') // must be absolute

const db = createDatabaseFromConfig(config, 'database-name')

const items = await db.list() 

console.log(items)

createDatabaseFromPath

import { createDatabaseFromPath } from '@sidekick-coder/db/database'

const db = createDatabaseFromPath('path/to/data/db.config.yml', 'database-name')

const items = await db.list()

console.log(items)