Setting Up MongoDB environment and performing CRUDQ operations

As I am using Windows 7 machine so in this post I am describing how to setup mongoDb on win 7 machine.

To verify the version of you windows open the command prompt and use following command

C:\>wmic os get osarchitecture


Since, MongoDB requires a data folder to store its files. The default location for the MongoDB data directory is c:\data\db


C:\>mkdir data
C:\ >cd data
C:\data\>mkdir db


Download and install the correct version of MongoDB from here.

To run MongoDB you need to goto <installation path>\bin in the command prompt OR add the <installation path>\bin as an environment variable
Execute the  command i.e.

<installation path>\bin >mongod   **this will use default data directory i.e. c:\data\db

OR In case you want to use different data directory then provide dbpath parameter.

<installation path>\bin >mongod -dbpath "path of data directory that you have created"



Congratulations!! Instance of MongoDB is up and running.


And now we need to perform basic CRUDQ operations on Database. So lets start with them.
For performing operations you need to open Mongo Shell. for that open command prompt and navigate to installation path and run "mongo"

<installation path>\bin >mongo 



1) Create: 

To create or use existing database 

use DATABASE_NAME
so now a new database with name "coderower" is created and is ready to use.
Its time to create a new collection and add a new record into it.
For creating a new collection use
db.createCollection(name, options)
where "name" is required parameter which is the name of the collection and "options" is optional and is of
FieldTypeDescription
cappedBoolean(Optional) If true, enables a capped collection. Capped collection is a collection fixed size collecction that automatically overwrites its oldest entries when it reaches its maximum size. If you specify true, you need to specify size parameter also.
autoIndexIDBoolean(Optional) If true, automatically create index on _id field.s Default value is false.
sizenumber(Optional) Specifies a maximum size in bytes for a capped collection. IfIf capped is true, then you need to specify this field also.
maxnumber(Optional) Specifies the maximum number of documents allowed in the capped collection.

Now its time to insert new document in the one of the created collections.
For that run a command 
>db.COLLECTION_NAME.insert(document)


Comments

  1. Casino Slots | tricktactoe.com
    Slots. 파워볼 중국점 사이트 벳무브 How do you choose the best casino games? A free 토토 승무패 넷마블 slot machine is what 먹튀 검증 커뮤니티 the 심바 토토 casino sbobet wants you to play: a combination of features,

    ReplyDelete
  2. Before the Free Game Feature, player chooses a gold expandable image to start out|to begin}. During Free Games, sport pays 2x when chosen gold image seems, chosen gold image expands to fill entire reel and wins are added. Wild image may set off a progressive bonus randomly in both the first sport and free video games. The sport options the All Up sport fashion, which supplies you 점보카지노 the chance to buy gold symbols to increase your profitable opportunities. That's basically finest way|the way in which} in which the house edge will get displayed for slots.

    ReplyDelete

Post a Comment

Popular posts from this blog

How to Build Mobile Apps for Online Marketplaces

The Growing Importance of Website Accessibility in the Digital Age

How to Choose the Right Software Development Company in 2023