← Back to Community
How to use Mongodb with Repl.it
Profile icon
IntellectualGuy

How Can I Use Mongodb with repl.it?

Voters
Profile icon
cybez
Profile icon
IntellectualGuy
Comments
hotnewtop
Profile icon
InvisibleOne

Yeah I use mongoDB, it works with Node or python. I don't use mongoose just require the actual mongodb module, and with python I use pymongo.

Profile icon
InvisibleOne

Note you can't actually use the local version of MongoDB, you have to use the atlas version, it's fee for the basic cluster which covers all my needs, but if you need a more serious database solution then you'll need to pay for servers, but I've done a lot of stuff and never really gotten close to the limit.

Profile icon
IntellectualGuy

@InvisibleOne Ok thanks, I use mongoose cause it's easier for me, but does mongodb atlas work the same way as the MongoDB Community Server?(I'm using node)

Profile icon
InvisibleOne

I'm not sure about that, but it isn't very hard to use, you just need the srv URL that they'll generate for you. @IntellectualGuy

Profile icon
EpicGamer007

Mongodb is not installed on replit so you need to find an external place for a mongodb database. You can achieve this with mongodb atlas which has a free tier. Then you need a mongodb client. For python, there is pymongo and for nodejs, there is mongoose. There are clients for other languages as well.

Profile icon
IntellectualGuy

@EpicGamer007 Okay, does mongodb atlas work the same way as the MongoDB Community Server?(btw I'm using node)

Profile icon
EpicGamer007

@IntellectualGuy yes, it will work the same. You can find many tutorials on youtube on how to get a free cluster with atlas then connecting to it

Profile icon
btfuss

Which language? Python: https://www.w3schools.com/python/python_mongodb_getstarted.asp, Node: https://www.w3schools.com/nodejs/nodejs_mongodb.asp, Javascript (iffy): https://stackoverflow.com/questions/7292648/mongodb-client-side-javascript-api . Just import these the way you normally would, if they don't work use their respective install methods!

these are all the languages that your profile said

Profile icon
IntellectualGuy

@btfuss I was asking how to use mongodb with node on replit(the language I'm using is Node)

Profile icon
btfuss

@IntellectualGuy Javascript link = node
Here is how you install: In the shell, npm install mongodb
Here is a base program:

var MongoClient = require('mongodb').MongoClient; var url = "mongodb://localhost:27017/mydb"; MongoClient.connect(url, function(err, db) { if (err) throw err; console.log("Database created!"); db.close(); });

I dont know anything further, refer to this link: https://www.w3schools.com/nodejs/nodejs_mongodb_create_db.asp