We have an external mongodb instance and we need to query data from it and bring it to Drupal 8 site.
On shell this is how we connect (mongodb is running in a different container than drupal)
mongo --host docker_mongo --ssl --sslCAFile=/etc/ssl/mongodb-cert.crt
Adding the following at settings.php does not work and status report shows "No database aliases found in settings. Did you actually configure your settings ?"
$configureMongoDb = function (array $settings): array {
$settings['mongodb'] = [
'clients' => [
// Client alias => connection constructor parameters.
'mymongo' => [
'uri' => 'mongodb://docker_mongo:27017',
'uriOptions' => ['ssl=true&sslCAFile=/etc/ssl/mongodb-cert.crt'],
'driverOptions' => [],
],
],
'databases' => [
// Database alias => [ client_alias, database_name ].
'tutorial2' => ['mymongo', 'tutorial2'],
],
];
return $settings;
};
Could anyone suggest how to connect to a mongodb instance?
Cross-posting this question at drupal-mongodb issue as well