#1 Re: mORMot 1 » MongoDB Atlas connecting to database / collection » 2019-03-05 10:17:29

thanks for your reply. First I thought, other client-apps are working, so it can't be a problem with the shards. But I figured out, that there are two secondary shards and one primary shard. When connecting to the primary shard, it's working! I can select a different collection and also retrieve data from it.

This helps a lot. Thank you very much!

#2 mORMot 1 » MongoDB Atlas connecting to database / collection » 2019-03-04 08:49:49

Radiesel
Replies: 2

Hi together,
I started using the mORMot framework because it support authentication using SCRAM-SHA-1. So far I setup a MongoDB Atlas cloud system through www.mongodb.com. I did setup a user in the "admin" database having also readwrite access to another database (lets call this "testdb"). So far I successfully was able to connect to the cloud database and even was able to authenticate the user against the admin database by using the follwing code:

var
  Client: TMongoClient;
  DB: TMongoDatabase;
  Coll: TMongoCollection;
  
  Client := TMongoClient.Create('shard0',27017,true,'shard1,shard2','27017,27017'); // connection string the cloud system gave me
  DB := Client.OpenAuth('admin','user','password');

This so far works and it seems user is successfully connected. But I am trying to access another database 'testdb' (which user has access to - some client-apps work w/o problems) by using this code:

  DB := Client.Open('testdb');
  Coll := DB.Collection['testcoll'];

Allthough "testdb" and "testcoll" exists on the server and user has access to it (client-apps are working and I already created some records), the last call isn't working.

So I am actually stuck, because I don't know what I am doing wrong here.

Any help would be appreciated. Best regards

Board footer

Powered by FluxBB