Hey guys
I just uploaded a video on my YouTube channel, to show you how install MongoDB and create Database, it is a very short tutorial but it can help you to understand some basic concepts of MongoDB.
YouTube link:
Bye bye
Hey guys
I just uploaded a video on my YouTube channel, to show you how install MongoDB and create Database, it is a very short tutorial but it can help you to understand some basic concepts of MongoDB.
YouTube link:
Bye bye
Hey Guys,
Now it is time to do some fantastic thing, normally connecting to database and retrieving data from database or writing into database is quite interesting if you are working with new platform and tools. Today I want to show you how to connect to the MongoDB and retrieve data (of course I will teach you how to insert first), for a few seconds forget about node.js and focus on MongoDB, in order to create a database in MongoDB we need to follow the below steps:
C:\MongoDB\Server\3.0\bin
After you moved to this folder key in the below command:
mongod –dbpath E:\node\notetest1\data
Note: dbpath is the address of data folder, so maybe your data folder address is different from mine, please change it accordingly.
Note: In some cases I saw that mongod does not work, so for this case you need to key in the full address of mongod.exe, actually mongod is exe file in bin folder!!!!
Note: it may take a few seconds to a few minutes for command to be finished so please be patient.
C:\MongoDB\Bin\mongo.exe
After you press enter you can see something like this:
To change the database you can type this command:
Use [name of you database]
Mongo DB uses Json data structure to keep data, so before we go further I want to show you how Json format looks like:
{“name”:”Mehran”,”code”:”123”}
{“name”:”Arash”,”code”:”234VF”}
{“name”:”Arman”,”code”:”EDRng”}
Basically json format is very simple and understandable for human.
How can we add record to our database?
In order to add records to your database you can use the below command:
db.insert.testcollection.insert({“name”:”Arman”,”code”:”EDRng”})
In the above command, testcollection is a user defined name for the collection. It means you can change it as you want. This collection looks like and array and keep all the records. Above command must be ran in mongo shell. (Same as step 5).
How can we retrieve records?
In order to retrieve data you can run the below command:
db.testcollection.find ().pretty ()
Then result is something like this:
{
“_id” : ObjectId(“55d1b2028f5be420d8a167fc”),
“name” : “Mehran”,
“code” : “123”
}
in the next post I will teach you how to retrieve data from MongoDb and show it Html file by using Node.js.
bye bye 🙂
Hey Guys,
I decided to start a tutorial about node.js. I know sounds is boring because there are plenty tutorials outside which can help you to learn. but in this tutorial I want to start differently. I want to start developing a real application. but we start it slowly and I will try to post a few times per day. before we start lets say why node.js ?
My answer to this questions is : because node.js is very cool. hahaha… but if you really want to know why node.js, you can look at this web page, this is a really good explanation about node.js
Any way, after you read Why Node.js, please do not waste your time to search about it. if you really want to know more about it, you only have one choice:
How we can install Node.Js?
Ok, this a first question that you may ask and it is right question. to install node.Js, Please click Node.Js and click on the Green INSTALL button ( I hope you can see it there !!!!! 😉 ). Just follow the install instruction and install the Node.Js,
Note: if you do not know how to install this app please turn off your PC and do something else. because installing node.js is as easy as installing Adobe Acrobat Reader 5.5.
How can check whether the Node.Js is installed properly or not?
it is a good questions. to check Node.Js installed properly or not, please open command prompt and type node -v
In response you may get something like this :
I think for now is enough, I will try to post new things :
Bye bye