How can i add different database name i.e one for development and other for production in mongodb atlas - mongodb

I want to add two different database for my node app in mongodb atlas in same cluster i.e. one for production and one for development but mongodb atlas is not showing databasename or myfirstfile after #cluster0.irbg7.mongodb.net/ in the below url. How do i add different database in such situations?

I assume that you already created the cluster. In one cluster you can add multiple Databases.
On your home page, you are able to see something like this.
Click on the Browse Collections to browse the collections.
Now create Database as much as you like.
To connect to the desired database, use the connection string followed by database name.
Example: 'mongodb://<username>:<password>#<clustername>/<dbname>?ssl=true&replicaSet=<replica setname>&authSource=admin

Related

Using Realm Sync with Atlas creates _realm_sync_ db that consumes lots of space

I am working on a mobile app with realm offline sync with Atlas.
While testing, I observed in MongoDb compass, one db is created automatically named _realm_sync_6380667787c967bc7e39bd68 which I didn't create. It's size is also keep on increasing when data is added to other dbs. I tried to drop it, but MongoDB compass didn't allow me to drop -> Msg "user is not allowed to do action [dropDatabase] on [__realm_sync_6380667787c967bc7e39bd68.]"
Can I delete this db, since I don't need it. It's size is much much larger than that of my actual db. Will it affect anywhere if I delete it?

how can we get data from mongodb in one docker project and insert into mongodb of another project

I have data in mongodb in one project.I am integrating this project functionality to another project,so I want to get whole data from the project and insert into this integration project.so much like data migration.
There is 2 parts to this.
First is the actual migration of date from 1 dB to another, u can use a any random tool to do that.
2nd is the docker networking part. So you can either get them to talk to each other by their ip, you can see them via docker inspect. However u need to manually do this everytime, the other is to use host.docker.internal, which means it will route it via your host pc, saving u having to find the up each time.

Create new MongoDB instance based on existing data

i want to dockerize my production application. I've got MongoDB set up on server and I want to remove it, and make a docker container with MongoDB which will work on existing data. I already tested this approach, so i created a docker container which storage is pointed to host storage with existing data. Basically it's the new MongoDB instance which work on data created by previous mongoDB which existed on Host. And it works, so i can query data, my application can connect to this database and so on. My question is, what are the threats to this approach? And if this is even good approach, or when i created new mongoDB instance should i import dump data from previous one ?
I guess there's no right and wrong in this case. It depends on how you want to have it working.
Let's say you left Mongodb running in the cloud.
Is it a development database? If yes, how would you keep coding / testing without access to that?

Meteor dynamic mongodb based on user

I develop a multi tenant application where each tenant has its own mongo db.
All tenants share the same UI.
I should have one mongo db for all users accounts and each mongo db for data.
I'm new in meteor and i would like to know how i can dynamically select the database when i publish the collections.
export const collects = new MongoObservable.Collection('collectionname',{
connection:DDP.connect('urltomongodb')
});
Any help please
As far as I know the DDP utilities are available for people who wish to connect to a Meteor server from a non-Meteor platform, either front end or server.
There is, of course, nothing to stop you using DDP.connect() to connect to another server, but you will also need to manage that connection, and any retries etc if it becomes unavailable.
I would suggest an easier path is to manage all of your data in one database - trying to separate them becomes non-trivial, because it is doing something that Meteor doesn't normally do. If you structure your data accordingly, it should be quite feasible to keep all the data in one database

RealStudio and PostgreSQL

To connect to the database I use this example. But I can't find lessons on how to create a database.
For example:
connect to server
create new database
do something
drop database
close connection
Can anybody show me how to do it?
Thanks!
Follow the manual on how to create a database cluster:
http://www.postgresql.org/docs/9.1/interactive/creating-cluster.html
The database and users are created only once and you can use the client applications for that. Or are you trying to do it automatically as part of a software install package? After that you connect to it as many times as needed.
Since you are creating a new database and then dropping it, why not use the built-in SQLite database? You can do a completely in-memory database that will be lightning fast (unless you fill up available RAM).
I believe you can create databases by issuing standard SQL commands just as you can create tables in a database, as long as you are using a user (e.g. admin or similarly entitled user) that has permissions to create new databases.
So, all you need is to connect to the DB with the right user and then issue SQL commands with db.SQLExecute, such as "create database newDBname".