How to connect and first use mongoDB

How to connect and first use mongoDB

How to connect and first use mongoDB

After installation mongodb now how we can use or we test to connected with databased ?? for the first you need to run mongod on your terminal. you can use npm or git bash for using two terminal, one for run mongod db terminal server and one again for run monggo command.
Just run command like this
And then terminal run mongod
After this now you can use npm or VScode other terminal for runing mongo or open mongo.exe on C:\Program Files\MongoDB\Server\4.2\bin\mongo.exe double clik on mongo.exe,and then just run the code
now you can start using mongodb , for the first you need know about comand monggo just run
and mongo display all function for using this db.
Now we can check and try run with
show dbs
And by default terminal displaying admin , config , and local.
Oke now lest try to create mongodb first, and run the code
use firstDB
And then enter.
automaticly db switched on firstDB,and ready to create database. you can check what db you use with run the command
And terminal display waht you DB your use.
now lest try to create table or database and run
_id: 1,
name: "Francis Nganou"
age: 31


And table databased is now creation, but how to check if database created ?? you can run
show collections
And the terminal display databased table.
And now how we can check what a database use it ?? you can run on the terminal
And then terminal displaying what database you use it.
Now how to check a database table we create before ?? you can just run the command with
and terminal is displaying detail about table you created.
Now how about update the data, in mongodb is a freedom database you can customises for what you need about table database. now if you need to update data like create new or insert in to table you can create or run command like this
db.user.updateOne({_id: 1},{$set: {gender:male}})
Now check it with run
And automaticly you have insert new table on database. yes... gender is a new you insert in to database user table, with mongo you can customise a database what you needed.for exmaple on user one with gender and user two without gender is a easy customises with using mongodb.
Now how to delete data from mongo ?? just simple you can run command
db.user.deleteOne({_id: 1})
And how to delete the databases ?? you must swith or use where database wan to delete, just run with "db" and then with run "use myDB", if you have selected and switch to database wan to delete now you can run commmand
Oke... i hope this Article How to connect and first use mongoDB help you to learn mongoDB.

Read how installtion mongoDB in here →

Tidak ada komentar:

Posting Komentar

Mesin Kasir News