Ask coding questions

← Back to all posts
How to use Mongodb with Repl.it
IntellectualGuy (822)

How Can I Use Mongodb with repl.it?

Comments
hotnewtop
InvisibleOne (2934)

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.

InvisibleOne (2934)

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.

IntellectualGuy (822)

@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)

InvisibleOne (2934)

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

EpicGamer007 (1765)

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.

IntellectualGuy (822)

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

EpicGamer007 (1765)

@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

btfuss (177)

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

IntellectualGuy (822)

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

btfuss (177)

@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