MongoDB
MongoDB is a NoSQL document database that provides flexible, schema-free data storage. LocalCloud includes MongoDB 7.0 with authentication and management tools.Features
- Document Database: Store data in flexible, JSON-like documents
- Indexing: Single field, compound, and text indices
- Aggregation: Powerful pipeline-based data processing
- Authentication: Built-in security with localcloud credentials
- Admin Interface: Web-based management via Mongo Express
- CLI Access: Direct mongosh integration via
lc mongo connect
Configuration
MongoDB is configured in yourlocalcloud.yaml file:
Connection Details
Connection String
Connection Parameters
- Host:
localhost - Port:
27017 - Username:
localcloud - Password:
localcloud - Database:
localcloud - Authentication Database:
admin
CLI Commands
Connect to MongoDB Shell
Database Operations
Collection Operations
Document Operations
Index Management
Usage Examples
Python with PyMongo
Node.js with MongoDB Driver
Go with MongoDB Driver
Web Interface
MongoDB includes Mongo Express for web-based administration:- URL:
http://localhost:8081 - Username:
admin - Password:
admin
- Browse databases and collections
- View and edit documents
- Manage indices
- Execute queries
- View collection statistics
Best Practices
Schema Design
Indexing
Aggregation Pipeline
Common Patterns
Document Validation
Transactions
System Requirements
- Memory: 1GB RAM minimum
- Storage: 1GB disk space for data
- Network: Port 27017 for MongoDB, 8081 for Mongo Express
Related Commands
lc mongo connect- Connect to MongoDB shelllc logs mongodb- View MongoDB logslc status- Check MongoDB statuslc stop mongodb- Stop MongoDB service