I have been trying to connect to a cluster in MongoDB Atlas using the mongodb:Client
. I am not able to find any connection string
that is supported by the Ballerina client. I could not find any sample code that suggests how to do so.
Following is the source code
import ballerinax/mongodb;
configurable string app = ?;
configurable string pwd = ?;
mongodb:Client mongoCli = check new ({connection: {url: string `mongodb+srv://${app}:${pwd}@fina-a-journey.ugfjnsm.mongodb.net/?retryWrites=true&w=majority`}});
public function main() {
mongodb:Error? insert = mongoCli->insert({name: "Jhon", age: 16}, "users");
}