Tuesday, January 8, 2019

Mongo DB


What is MongoDB

  • Document oriented database
  • High performance,
  • High availability
  • Easy scalability.

How to install Mongo DB in ubuntu

  • To install mongoDB on ubuntu, type theses two commands in terminal
    • sudo apt-key adv --keyserver
    • hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
  • To start mongo DB
    • sudo mongo - Start server
    • sudo mongod - Start Client

Data Type

  • String − This is the most commonly used datatype to store the data. String in MongoDB must be UTF-8 valid.
  • Integer − This type is used to store a numerical value. Integer can be 32 bit or 64 bit depending upon your server.
  • Boolean − This type is used to store a boolean (true/ false) value.
  • Double − This type is used to store floating point values.
  • Min/ Max keys − This type is used to compare a value against the lowest and highest BSON elements.
  • Arrays − This type is used to store arrays or list or multiple values into one key.
  • Timestamp − ctimestamp. This can be handy for recording when a document has been modified or added.
  • Object − This datatype is used for embedded documents.
  • Null − This type is used to store a Null value.
  • Symbol − This datatype is used identically to a string; however, it's generally reserved for languages that use a specific symbol type.
  • Date − This datatype is used to store the current date or time in UNIX time format. You can specify your own date time by creating object of Date and passing day, month, year into it.
  • Binary data − This datatype is used to store binary data.
  • Code − This datatype is used to store JavaScript code into the document.
  • Regular expression -This datatype is used to store regular expression.

Insert Document

  • db.COLLECTION_NAME.insert(document)

Query Document

  • db.COLLECTION_NAME.find()
  • db.mycol.find().pretty()

Update Document

  • db.COLLECTION_NAME.update(SELECTION_CRITERIA, UPDATED_DATA)
  • db.COLLECTION_NAME.save({_id:ObjectId(),NEW_DATA})

Delete Document

  • db.COLLECTION_NAME.remove(DELLETION_CRITTERIA)
  • Remove Only One
    • db.COLLECTION_NAME.remove(DELETION_CRITERIA,1) 

Aggregation

  • $sum
  • $avg
  • $min
  • $max
  • $push
  • $addToSet
  • $first
  • $last

Referance : image https://www.mongodb.com/
https://www.progress.com/blogs/mongodb-odbc-driver-sql-access-to-mongodb-nosql-data

No comments:

Post a Comment