MongoDB package is available on the UBUNTU repository. So we have to just install it using the command line.
Update the repository to the latest version of MongoDB
sudo apt-get update
Start the MongoDB server
sudo service mongodb start
You can communicate with the MongoDB server using mongo shell.
mongo command will take us to the mongo shell
It will connect to default database test
For creating the database the command is 'use'. In the process of creation of database the mongoDB creates a new database or it will connect to the existing database.
Let's create a database name 'mydb'
Now let's create some collection using,
You can find the collection using,
Update the repository to the latest version of MongoDB
sudo apt-get update
Start the MongoDB server
sudo service mongodb start
You can communicate with the MongoDB server using mongo shell.
mongo command will take us to the mongo shell
It will connect to default database test
For creating the database the command is 'use'. In the process of creation of database the mongoDB creates a new database or it will connect to the existing database.
Let's create a database name 'mydb'
Now let's create some collection using,
You can find the collection using,
Query and Write Operation Commands
Name | Description |
---|---|
find |
Selects documents in a collection. |
insert |
Inserts one or more documents. |
update |
Updates one or more documents. |
delete |
Deletes one or more documents. |
findAndModify |
Returns and modifies a single document. |
getMore |
Returns batches of documents currently pointed to by the cursor. |
getLastError |
Returns the success status of the last operation. |
getPrevError |
Returns status document containing all errors since the last resetError command. |
resetError |
Resets the last error status. |
eval |
Deprecated. Runs a JavaScript function on the database server. |
parallelCollectionScan |
Lets applications use multiple parallel cursors when reading documents from a collection. |
No comments:
Post a Comment