MongoDB Viewer

MongoDB Access Options

Here are several ways to explore your MongoDB databases on this server:

Option 1: MongoDB Shell

The most direct way to access MongoDB is using the MongoDB Shell (mongosh) directly on the server:

Connect to your server

Start MongoDB Shell:
mongosh

Common MongoDB Commands:
show dbs - List all databases
use jobs_db_a - Switch to a database
show collections - List collections in current database
db.jobs_history.find().limit(5) - Show 5 documents from jobs_history
db.jobs_history.countDocuments() - Count documents in collection
db.jobs.find({title: "Software Engineer"}) - Find by criteria
Option 2: Install Mongo Express

For a web-based admin interface, you can install Mongo Express with Docker:

1. Install Docker (if not already installed):
sudo apt update
sudo apt install docker.io

2. Create a Docker Compose file:
nano mongo-express.yml

3. Paste this configuration:
version: '3'
services:
  mongo-express:
    image: mongo-express:latest
    container_name: mongo-express
    restart: always
    ports:
      - "8081:8081"
    environment:
      - ME_CONFIG_MONGODB_SERVER=localhost
      - ME_CONFIG_MONGODB_PORT=27017
      - ME_CONFIG_MONGODB_ENABLE_ADMIN=true
      - ME_CONFIG_BASICAUTH_USERNAME=admin
      - ME_CONFIG_BASICAUTH_PASSWORD=password
    network_mode: host

4. Run Mongo Express:
sudo docker-compose -f mongo-express.yml up -d

5. Access Mongo Express:
http://jobs-api.mikeylong.com:8081
MongoDB Database Overview
Main Database Structure: (Loading stats...)
MongoDB Shell Examples for Common Tasks:
// Find the 5 most recent jobs in history
use jobs_db_a
db.jobs_history.find().sort({created_at: -1}).limit(5)

// Find rejected jobs by reason
db.rejected_jobs.find({reason: {$regex: "experience"}})

// Count LinkedIn jobs by company
use jobs_api
db.linkedin_job_tracking.aggregate([
  {$group: {_id: "$latest_job_data.company", count: {$sum: 1}}},
  {$sort: {count: -1}}
])

// Create index on a frequently queried field
db.jobs_history.createIndex({company: 1})