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

@mohamed1_1ibrahim/dcli

v1.1.1

Published

Database CLI - MongoDB data management tool (export, import, ping, info)

Readme

dcli — Database CLI

dcli (short for Database CLI) is a command-line tool for MongoDB data management. Designed for terminal use.

Features

  • export — Export a MongoDB database to JSON file(s)
  • import — Import a database or specific collection(s) from JSON file(s)
  • ping — Ping databases to prevent idle/inactivity pause
  • info — Show database collections and document counts
  • add — Register a database URI in the auto-ping list (with optional name)
  • remove — Remove a database by URI or friendly name
  • auto-ping — Schedule dcli ping to run automatically on Windows logon
  • view — Browse collections and documents in a styled table
  • show — Display the auto-ping or auto-clone database list
  • clone-add — Register a database URI in the auto-clone list
  • clone-remove — Remove a database from the auto-clone list
  • clone — Clone a single database by friendly name to JSON
  • auto-clone — Clone all databases in the clone list to JSON files
  • gui — Launch the web GUI in your browser

Installation

npm install -g @mohamed1_1ibrahim/dcli
git clone https://github.com/Mohamed-Ibrahim183/dcli
cd dcli
npm install
npm link

Usage

export

Export a MongoDB database to JSON file(s). Output is prettified by default.

dcli export "mongodb://localhost:27017/mydb"

| Option | Description | |--------|-------------| | -o, --output <name> | Output name (without or with .json extension) | | --format <type> | file (single JSON), split (per collection), all (both) | | --compact | Minify JSON output (default is prettified) | | --include <collections...> | Only export these collections | | --exclude <collections...> | Skip these collections | | --dry-run | Preview without writing files |

If the output file already exists, it auto-increments — file.jsonfile (1).jsonfile (2).json.

dcli export "mongodb://..." -o mydata
dcli export "mongodb://..." --format split
dcli export "mongodb://..." --format all --compact
dcli export "mongodb://..." --include users posts
dcli export "mongodb://..." --exclude logs analytics
dcli export "mongodb://..." --dry-run

import

Restore from a full file, single collection file, or directory.

| -f path | Behavior | |-----------|----------| | Full .json file | Restore entire DB (backup + confirmation + drop) | | Single collection .json | Restore that collection only | | Directory of .json files | Restore each file as a collection |

dcli import "mongodb://localhost:27017/mydb" -f backup.json
dcli import "mongodb://..." -f ./users.json
dcli import "mongodb://..." -f ./collections/

ping

Ping databases to prevent inactivity pause.

dcli ping                          # ping all from config
dcli ping "mongodb://..."          # ping a raw URI
dcli ping dbName                   # ping by friendly name from config
dcli ping --file my-dbs.json       # ping all from a custom file

info

Show collections and document counts.

dcli info "mongodb://localhost:27017/mydb"

add / remove

Manage the auto-ping list (~/.dcli/refresh.json).

dcli add "mongodb://..." -n dbName          # add with friendly name
dcli add "mongodb://..." -n dbName          # updates name if URI already exists
dcli remove "mongodb://user:pass@..."       # remove by URI
dcli remove dbName                          # remove by friendly name

auto-ping

Schedule dcli ping to run automatically. Requires administrator privileges.

dcli auto-ping                       # ONLOGON, 5 min delay (default)
dcli auto-ping --remove              # remove the task
dcli auto-ping --schedule DAILY --at 09:00
dcli auto-ping --schedule HOURLY --every 2
dcli auto-ping --schedule ONCE --at 18:00
dcli auto-ping --schedule ONLOGON --delay 10

| Option | Description | |--------|-------------| | --remove | Remove the scheduled task | | --schedule <type> | ONLOGON, DAILY, HOURLY, or ONCE (default: ONLOGON) | | --at <time> | Time for DAILY/ONCE schedules (24h, e.g. 09:00) | | --every <n> | Interval in hours for HOURLY (default: 1) | | --delay <n> | Delay in minutes for ONLOGON (default: 5) |

view

Browse collections and documents in a styled table.

dcli view "mongodb://localhost:27017/mydb"              # list collections
dcli view "mongodb://localhost:27017/mydb" users         # browse documents
dcli view "mongodb://..." users --limit 5
dcli view "mongodb://..." users --fields name,email --sort name
dcli view "mongodb://..." users --all --json

| Option | Description | |--------|-------------| | --limit <n> | Maximum documents (default: 10) | | --fields <fields> | Comma-separated fields to display | | --sort <field> | Sort ascending by field | | --all | Show all documents (no limit) | | --json | Output raw JSON instead of a table |

show

Display the auto-ping or auto-clone database list.

dcli show              # show ping list (~/.dcli/refresh.json)
dcli show --clone      # show clone list (~/.dcli/auto-clone.json)

clone-add / clone-remove

Manage the auto-clone list (~/.dcli/auto-clone.json).

dcli clone-add "mongodb://..." -n dbName
dcli clone-remove dbName

clone

Clone a single database from the clone list to a JSON file.

dcli clone dbName
dcli clone dbName -o ./backups

auto-clone

Clone all databases in the clone list to JSON files.

dcli auto-clone
dcli auto-clone -o ./backups

gui

Launch the web GUI in your browser (port defaults to 3456).

dcli gui
dcli gui -p 8080

Config Files

Ping list~/.dcli/refresh.json:

{
  "databases": [
    { "uri": "mongodb://cluster0.example.mongodb.net/mydb", "name": "dbName" },
    "mongodb://backup.example.mongodb.net/otherdb"
  ]
}

Clone list~/.dcli/auto-clone.json (same format as above).

Entries can be objects with uri and optional name, or plain strings (backward compatible). Many commands also accept a friendly name in place of a URI (e.g. dcli ping dbName).

Export Format

Single file:

{
  "database": "mydb",
  "exportedAt": "2026-05-25T14:30:00.000Z",
  "data": {
    "users": [ { "_id": "...", "name": "Alice" } ],
    "posts": [ { "_id": "...", "title": "Hello" } ]
  }
}

Split (per collection in a folder):

folder/
├── users.json     [ { "_id": "...", ... }, ... ]
├── posts.json     [ { "_id": "...", ... }, ... ]

Dependencies