Start
Quickstart
Get a connection string and run your first queries with the Python and Node.js MongoDB drivers.
On this page
This page connects an existing driver to a FENVIX database. <endpoint> below stands for the host shown on the database's page in the dashboard.
1. Get a connection string#
A connection string uses the MongoDB protocol. Replace the host of your current connection string with the FENVIX endpoint and keep the rest.
# before
mongodb+srv://<user>:<password>@<your-current-host>/acme
# after
mongodb://<user>:<password>@<endpoint>/acmeThe database name in the path (acme here) selects the database. The first request to a sleeping database wakes it.
2. Connect with Python#
Install the driver, then connect, insert and read back.
pip install pymongofrom pymongo import MongoClient
client = MongoClient("mongodb://<user>:<password>@<endpoint>/acme")
db = client["acme"]
db.orders.insert_one({"status": "paid", "total": 42})
print(db.orders.find_one({"status": "paid"}))3. Connect with Node.js#
npm install mongodbimport { MongoClient } from "mongodb";
const client = new MongoClient("mongodb://<user>:<password>@<endpoint>/acme");
await client.connect();
const db = client.db("acme");
await db.collection("orders").insertOne({ status: "paid", total: 42 });
console.log(await db.collection("orders").findOne({ status: "paid" }));
await client.close();4. Query as before#
Aggregations work the same way. This example uses $match and $lookup, both in the supported set listed under Compatibility.
const paid = await db.collection("orders").aggregate([
{ $match: { status: "paid" } },
{ $lookup: { from: "users", localField: "userId", foreignField: "_id", as: "user" } },
]).toArray();