July 4, 2020

Basic MongoDB Commands for Smart IT.

To run the commands, we need to first connect to social database which is database for Smart IT and for this we use Mongo Shell.Below are the steps to connect to Mongo Shell.

1.Login to Server where Mongo DB is installed.
2.Navigate to Mongodb folder. In my case as it is installed at location. <C:\Program Files\BMC

3.Software\SmartITMyIT\Smart_IITIT\mongodb\bin>
In case of linux, the file path is </opt/bmc/SmartITIT/SmartITMyITongodb/bin>
4.At this location, you will find a file called "mongo", execute it. it open mongo shell.
5.On Mongo shell, run command "use social".
6. This connects us to social DB

Once we are connected to Social DB, we can below command to find specific set of data.Below are some basic commands that may be helpful to you. learn MongoDB online training from industrial experts.

MongoDB commands

MongoDB Commands Listing (Administrative Command Helpers):
The sections above provide helpful commands that can get you online on MongoDB and do some administrative tasks on MongoDB. This section specifically works upon the administrative tasks on databases created within MongoDB database server.
JS Database Administration Method
1. db.cloneDatabase()
2. db.copyDatabase(, , )
3. db.fromCollection.renameCollection(toCollection)
4. db.repairDatabase()
5. db.getCollectionNames()
6. db.dropDatabase()

1. Query Mongo DB to check Incident/Change/Knowledge etc Records.
In order to find the record details, we need InstanceID of the record. once we have it, paste it in place of "InstanceID" in below command and execute it.

2. Query MongoDB to check Subjectivity for Incident.
We use this command to check if the workinfo/activity for Parent record exists or not.

3. To find specific user profile based on Login ID.
In case one needs to check if user details exits in MongoDB, we use below command.

4. Delete Activities and Sub-activities associated with a user "Allen"
In a situation, if there a need to delete the activities and activities associated with a user then we can use below command to achieve it. MongoDB online course will helps you to learn more effectively.

MongoDB Commands Listing (Basic Shell JS Operations) :
Apart from the above help options and command-line options, MongoDB provides a rich collection of Javascript API for database related operations. DB is the mongo shell variable that holds the current database that we are pointing to. The variable is reset to the when the command is used, until then it points to the test database.

Some of the commonly used Javascript operations
1 db.auth()
2 myCollectionVariable = db.
3 db.collection.find()
4 db.collection.insertOne()
5 db.collection.insertMany()
6 db.collection.updateOne()
7 db.collection.updateMany()
8 db.collection.save()
9 db.collection.deleteOne()
10 db.collection.deleteMany()
11 db.collection.drop()
12 db.collection.createIndex()
exist. If the index already exists, then there is no effect of this command over the collection specified by the command.

Conclusion:
This article provides a one-stop-shop for all the administration related queries, help related commands and the basic CRUD operations that can be done on collections on a MongoDB database. As mentioned earlier during the introduction of the article, this is written for the latest stable release of MongoDB. For more details learn mongodb online
Commands provided here may not work on other versions of MongoDB considering that there are many changes from the previous versions to the latest one.