Skip to main content
The jasonisnthappy REPL (Read-Eval-Print Loop) provides an interactive shell for exploring and managing databases. It’s similar to the MongoDB shell or Redis CLI.

Starting the REPL

There are two ways to enter interactive mode:
jasonisnthappy mydb.db --interactive

With web UI

Launch the REPL with the built-in web interface:
jasonisnthappy mydb.db --interactive --web-ui

REPL prompt

The prompt changes based on context:
db>          # No collection selected
users>       # Collection 'users' is active

Available commands

Database commands

db> info

Collection commands

db> use users
After using use <collection>, the prompt changes to show the active collection name.

Document commands

All document commands operate on the currently selected collection:
users> insert {"name":"Alice","age":30}

Index commands

users> indexes

Import/export

users> export users_backup.json

Help and exit

db> help
Press Ctrl+C to cancel the current line. Press Ctrl+D or type exit to quit.

Example session

Here’s a typical REPL workflow:
$ jasonisnthappy mydb.db
jasonisnthappy interactive shell
Database: mydb.db
Type 'help' for available commands, 'exit' to quit

db> collections
Collections (2):
 users (45 documents)
 orders (123 documents)

db> use users
 Now using collection 'users'

users> find {"age":{"$gte":30}}
Found 12 documents:

Document ID: 1
{
  "name": "Alice",
  "age": 30,
  "email": "alice@example.com"
}

Document ID: 5
{
  "name": "Bob",
  "age": 35,
  "email": "bob@example.com"
}

users> count {"age":{"$gte":30}}
Count: 12 documents

users> exit

REPL features

Command history

The REPL maintains a command history that persists between sessions:
  • Press (up arrow) to navigate to previous commands
  • Press (down arrow) to navigate to next commands
  • Type and press to search history for matching commands

Line editing

Full readline support is available:
  • Ctrl+A - Move to beginning of line
  • Ctrl+E - Move to end of line
  • Ctrl+K - Delete from cursor to end of line
  • Ctrl+U - Delete from cursor to beginning of line
  • Ctrl+W - Delete word before cursor

Auto-completion

Command names are automatically completed (future feature).

Output formatting

Set the default output format when starting the REPL:
jasonisnthappy mydb.db -i --format pretty
The format applies to all REPL commands. Use --format json for scriptable output.

Working with JSON

Multi-line JSON

The REPL automatically detects incomplete JSON and allows multi-line input:
users> insert {
...   "name": "Alice",
...   "profile": {
...     "age": 30,
...     "city": "Boston"
...   }
... }
 Document inserted

Complex queries

Complex queries can span multiple lines:
users> find {
...   "$or": [
...     {"age": {"$lt": 18}},
...     {"age": {"$gte": 65}}
...   ],
...   "status": "active"
... }

Tips and tricks

Quick database inspection: Run jasonisnthappy mydb.db without -i to see database info and exit immediately.
Test queries safely: Use find to preview documents before running update or delete commands.
Export for backup: Regularly export important collections with export <file> for point-in-time backups.
Check before dropping: Run count or find before drop to verify you’re deleting the right collection.

Error handling

The REPL provides friendly error messages:
users> insert {invalid json}
 Error: Invalid JSON: expected value at line 1 column 2

db> use
 Usage: use <collection>

users> update {"name":"Alice"}
 Usage: update {query} {update}

Comparison with CLI commands

REPL commands are simpler than full CLI commands:
db> use users
users> find {"age":{"$gte":25}}
users> insert {"name":"Alice"}
The REPL is ideal for exploration and development. Use CLI commands for automation and scripting.

Document commands

Full CLI syntax for documents

Database commands

Full CLI syntax for databases

Build docs developers (and LLMs) love