Here are several ways to explore your MongoDB databases on this server:
The most direct way to access MongoDB is using the MongoDB Shell (mongosh) directly on the server:
mongoshshow dbs - List all databasesuse jobs_db_a - Switch to a databaseshow collections - List collections in current databasedb.jobs_history.find().limit(5) - Show 5 documents from jobs_historydb.jobs_history.countDocuments() - Count documents in collectiondb.jobs.find({title: "Software Engineer"}) - Find by criteria
For a web-based admin interface, you can install Mongo Express with Docker:
sudo apt updatesudo apt install docker.ionano mongo-express.ymlversion: '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: hostsudo docker-compose -f mongo-express.yml up -dhttp://jobs-api.mikeylong.com:8081
// 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})