// MongoDB replica set initialization script
// Runs on first startup via /docker-entrypoint-initdb.d/
try {
  rs.initiate({
    _id: 'rs0',
    members: [{ _id: 0, host: 'mongodb:27017' }],
  });
  print('Replica set initiated successfully');
} catch (e) {
  if (e.codeName === 'AlreadyInitialized') {
    print('Replica set already initialized');
  } else {
    print('Error initiating replica set: ' + e.message);
  }
}
