What is MongoDB?
Official DocsTL;DR
NoSQL document database integrated into Frontend Accelerator via adapter pattern for flexible data storage
MongoDB is a popular NoSQL document database that stores data in flexible, JSON-like documents. In Frontend Accelerator, MongoDB is integrated through an adapter pattern, allowing you to use MongoDB as your database while maintaining the flexibility to switch to other databases like Firestore or others, without rewriting your application logic.
The database adapter provides a unified interface for data operations. When configured with MongoDB, the adapter translates standard CRUD operations into MongoDB-specific queries, handles connection pooling, and manages schema validation.
Example configuration:
// Configure env variable
MONGO_DB_URI="mongodb+srv://..."
const db = new Database();
// Create user
await db.createUser({
email: 'user@example.com',
name: 'John Doe',
createdAt: new Date()
});
// Query users
const users = await db.findUser("Tomas");
Key features:
- Document model: Flexible schema-less data structure
- Scalability: Horizontal scaling with sharding support
- Rich queries: Complex filtering, sorting, and aggregation
- Indexing: Optimize query performance with indexes
- Atlas cloud: Managed cloud database service
Adapter pattern benefits:
- Database agnostic: Switch from MongoDB to Firestore or other databases easily
- Consistent API: Same interface regardless of underlying database
- Migration ready: Change databases without rewriting business logic
- Testing support: Use in-memory databases for testing
- Type safety: Full TypeScript support with schema validation
AI-friendly: The MongoDB adapter in Frontend Accelerator uses a standardized interface that makes it easy for AI to understand and work with. AI assistants can help design schemas, write queries, optimize indexes, handle migrations, and debug database issues without needing deep MongoDB expertise.