// MongoDB initialization script for Docker // This script runs when the MongoDB container starts for the first time // Switch to the application database db = db.getSiblingDB('nextjs-boilerplate') // Create an application user with read/write permissions db.createUser({ user: 'app', pwd: 'apppassword', roles: [ { role: 'readWrite', db: 'nextjs-boilerplate', }, ], }) // Create indexes for better performance db.users.createIndex({ email: 1 }, { unique: true }) db.users.createIndex({ createdAt: 1 }) // Insert sample data (optional) db.users.insertOne({ name: 'System Admin', email: 'admin@example.com', password: '$2a$12$LQv3c1yqBWVHxkd0LHAkCOYz6TtxMQJgV3NI7UxrNhVbqjKUpwZAC', // hashed: admin123 role: 'admin', createdAt: new Date(), updatedAt: new Date(), }) console.log('Database initialized successfully')