How does Meteor connect to Mongo? - mongodb

Very new to Meteor.
I am trying to make a separate worker process that uses the ddp and ddp-login packages to log in to my main Meteor app's Mongo collections over DDP.
It is prompting for credentials.
My questions are:
What are the default credentials Meteor sets up to connect to Mongo?
Where are these located in the Meteor project? Where is the connection string?
How do I change these credentials?
I have been hunting all over my project source and it's still "magical" to me.

Related

How to choose MongoDB Connect to Cluster option?

I'm new to MongoDB and I'm having some problems with MongoDB recently.
I'm not sure about Connect with the MongoDB Shell, Connect your application, Connect using MongoDB Compass, what's the difference?
The current demand is. I want to directly allow connection from anywhere and create a user account password to log into this database, which option should I choose?
https://i.stack.imgur.com/iwYMf.png
In Connect your application tab, you get a link that you need to copy
and paste in your application you are building to connect it to the
database. Remember to replace your password and databse name.
In Connect using MongoDB Compass tab, you get a link that you need
to paste in your compass application(A desktop application that
makes your mongodb data handling so much easier). And again remember to replace
your credentials.
I'm not very fond of Mongodb shell. It's actually an extensible
command-line interface.

How to transfer a database from MongoDB Compass to MongoDB Atlas

I have an existing database for a discord bot in MongoDB Compass v1.28.1 I want to transfer all the data in the database to mongodb atlas because of its more extensive functionality and to not have to wait for compass to take ages to load each time I open it. However when I follow the steps to connect that are provided in Atlas, the pop-up that's supposed to appear when I copy a path to the clipboard doesn't appear, and nothing happens. I tried to connect through my app in VSCode, the same way I did for Compass, using mongoose. Still no collections are loading or any data being stored. I have made my schemas etc. which work perfectly fine in Compass...
Migration to Atlas is documented at https://docs.atlas.mongodb.com/import/
To save you some reads, you have to options - export/import and mongodump/mongorestore.
I would recommend to try export/import first. It's built into Compass https://docs.mongodb.com/compass/current/import-export/ and must be simpler to use considering limited experience with mongo. It's UI oriented so just follow the click-through guide in the documentation.
Unfortunately it has some limitations related to data type conversion from BSON to JSON and may be a bit tedious if you have large number of collections.
In this case you will need to follow CLI mongodump/mongorestore way #barrypicker suggested in the comments. Both commands are available in cmd and PowerShell consoles.
First you backup your local database https://docs.mongodb.com/v4.2/reference/program/mongodump/:
mongodump --uri="mongodb://username:password#localhost:27017/discordbot"
username and password are the ones you use in compass to connect to the source database.
It will create dump directory with all collections you have.
Then you have to upload the backup to Atlas:
mongorestore --uri="mongodb+srv://username:password#cluster.tenant.mongodb.net/database" dump/
username and password are the ones you use to connect to atlas cluster, listed in the "Security/Database Access" section.
You can get the exact subdomains for the --uri part from Atlas. In the dashboard click "Connect" button for the cluster you want to connect to, then choose "shell" as the connection method in the connection pop-up:

Connect external mongodb with private key ( file.pem ) and user without mongo_url

Hello I’m new Meteor !!!
I have only private key (file.pem), user, ip:port
I don’t know how to connect with meteor run on local machine
First try to connect with some local client, terminal or robomongo. After you managed to do that, you can look into ways to connect your meteor application to external mongodb.
Also since meteor coming with its own bundled mongo, you should install mongodb in your system and connect your meteor app to this one mongo first.

How to perform something like meteor reset on deployed app?

I have an app deployed on digital ocean and am trying to perform a meteor reset to reset the DB etc. Where is meteor located when deployed via mup? I keep getting a command not recognized with meteor commands.
As far as I know you can't run meteor reset on deployed apps like that as it's already been built by MUP. The way you could mimic a meteor reset is to run the mongo shell on your digital ocean server:
mongo
You can check what the databases are by using:
show dbs
and then access the one meteor is running by doing:
use [db name]
and then manually drop the databases by using:
db.[collection name].drop()
http://docs.mongodb.org/manual/reference/method/db.collection.drop/
Meteor already has the user collection defined so you'd probably want to drop that collection too if you want a clean start

How to persist mongodb when deploying with meteor?

When I meteor deploy my app, it seems to create an entirely new mongodb instance. I'd like to be able to deploy with the current mongodb have locally.
Same goes the other way -- I'd like to be able to download the mongodb back to my localhost after it has been deployed.
For clarification, I'd really like to know the follow:
1) how to deploy with a fresh mongodb
2) how to deploy to an existing deployed app without overwriting the old mongodb
3) how to download/sync mongodb locally with the existing deployed app
4) how to make local backups of mongodb
You can perform a mongo dump using meteor mongo to export your local database and deploy your app using Meteor Up which should also allow you to automate the database import and deployment process.
"Meteor Up (mup for short) is a command line tool that allows you to deploy any meteor app into your own server."
You can stop the mongodb service and start a mongod instance in a separate terminal, by just typing mongod. This will let you monitor what's happening on the mongodb instance that you just started.
Open another terminal and do export MONGO_URL=mongodb://localhost:27017/nameOfDBgoesHere
This will create a new DB named "nameOfDBgoesHere" and it won't overwrite what you currently have, unless you name it with the same name.
After that just start meteor by typing meteor in your program's folder. In the mongod terminal that you opened you should see some connections opening.
By default mongodb creates it's DB files in /data/db. If you have another meteor app and follow the same steps in another terminal, while keeping the name of the DB you specified in the MONGO_URL you will just connect to it from that app - without overwriting anything.
As for the syncing with a deployed app and the local backups of mongo - it seems like something that the mongodb website covers, but maybe someone can chime in here. Not sure if there is a meteor specific, easy way of doing this.