Connect
Connect with mongosh and with the official MongoDB driver for your language.
TeselaDB presents itself to drivers as a MongoDB mongos, so any official driver and mongosh connect without changes. You only need three things: the address of a node, a user and the cluster CA, because the client port always requires TLS.
The connection string
mongodb://root:<password>@127.0.0.1:27017/?tls=true&tlsCAFile=./data/pki/ca.pemtls=trueturns TLS on. Without it, the node refuses the connection.tlsCAFilepoints topki/ca.pemin the data directory of the first node. Copy that file to the machines of your applications; it is not a secret.- The
rootpassword is inroot-credentials.txt. For your applications, create their own user with only the roles they need (see Users and roles).
mongosh
Shell
mongosh "mongodb://root:<password>@127.0.0.1:27017/?tls=true&tlsCAFile=./data/pki/ca.pem"From your language
Every official driver accepts the same connection string. These are four examples; the other drivers (C#, Rust, PHP, Ruby, Kotlin, Swift, C and C++) work the same way.
Node.js
JavaScript
import { MongoClient } from "mongodb";
const client = new MongoClient("mongodb://root:<password>@127.0.0.1:27017/?tls=true&tlsCAFile=./data/pki/ca.pem");
await client.connect();
await client.db("shop").collection("orders").insertOne({ total: 149.5 });Python
Python
from pymongo import MongoClient
client = MongoClient(
"mongodb://root:<password>@127.0.0.1:27017/?tls=true&tlsCAFile=./data/pki/ca.pem"
)
client.shop.orders.insert_one({"total": 149.5})Go
Go
client, err := mongo.Connect(options.Client().ApplyURI(
"mongodb://root:<password>@127.0.0.1:27017/?tls=true&tlsCAFile=./data/pki/ca.pem",
))
if err != nil {
panic(err)
}
_, err = client.Database("shop").Collection("orders").InsertOne(ctx, bson.M{"total": 149.5})Java
Java
try (MongoClient client = MongoClients.create(
"mongodb://root:<password>@127.0.0.1:27017/?tls=true&tlsCAFile=./data/pki/ca.pem")) {
client.getDatabase("shop").getCollection("orders").insertOne(new Document("total", 149.5));
}Several nodes in the string
Any node routes each request to the range it touches, so one is enough. Put two or three in the string so the driver has another to go to if one does not answer:
mongodb://node-01:27017,node-02:27017,node-03:27017/?tls=true&tlsCAFile=./ca.pemNext step
Add more nodes and watch the ranges spread: Your first cluster.