Db connection with Atlas, dev and prod part (using node+express)

Hi @Marco_A and welcome in the MongoDB Community !

First, yes, you are correct, you can only have one M0 cluster per Atlas project. So if you want your dev and prod running on an M0 cluster, you will have to create 2 Atlas projects.

That being said, M0 are just shared instances and are not reliable enough for production environment. Please consider using at least an M10 for a production environment which is the first dedicated tier.

When you create a cluster in Atlas, which ever tier you create from M0 to M700, by default it’s a replica set of 3 machines running in the background. The cluster you see on Atlas is “just” the hardware + the mongod daemons running (and configured correctly).

Databases lives inside the cluster. If you want to create a database, head into the collection tab:

Then click on “create databse”.

You will also have the option their to create a collection which is a set of documents. A collection lives inside a database.

That being said, you don’t need to create any database or collection. In MongoDB, they are created automatically when you write the first document in them.

Example:

test:PRIMARY> use new_database
switched to db new_database
test:PRIMARY> db.new_collection.insert({"new":"document"})
WriteResult({ "nInserted" : 1 })
test:PRIMARY> db.new_collection.findOne()
{ "_id" : ObjectId("60217d05fefe8bffdab5ee20"), "new" : "document" }
test:PRIMARY> show dbs 
admin         0.000GB
config        0.000GB
local         0.000GB
new_database  0.000GB
test          0.000GB
test:PRIMARY> show collections
new_collection

I hope this helps.

Cheers,
Maxime.