Backend Topics
Published: 2021-12-23 10:15:37

**1 . CRUD Operations :**  CRUD  operations  is  backend database management system  
    which  helps to create ,read , update  and delete documents .
   Create Operations:   It is a creating  or inserting  method  . It means when  collection doesn’t  
   exists   this insert operations will add or create new documents to the collection . In MongoDB  
   creating  operations  may  follow this way :
**db.collection.insertOne ()   [ It is use for inserting one new document  to  collections ]
db.collection.insertMany ()   [ It is use for inserting many new documents to collections ] 
One inserting  document  code is here to see :**
**db.products.insertOne (
  {
   name : “ Bag ”,
   price : “ 22 “ ,
   rating  : “ 4 ”
  }
)**

   **Read Operations:**  It  is a query  method  of document collection .  It finds out our searching  
   collections  from mongoDB  may or from other databases . We   can search data from  one  or  
   more  data from the database by using these read operations . That means  it can  easily  
   specify   criteria and filter  them  then return these documents .
 **db.collection.findOne ( query things are here )   [ It is use for finding one  document from collections ]
db.collection.find ([ ])   [ It is use for  finding many documents from  collections ] 
   One example is here : 
   db. products. find (
       {  price :  { $ price : 15} },
        { name : 2  }
   ) .limit ( 6 )**
    

  Read operations follow different  query methods for  searching our needs . Like 
Can query  one  document from a database based on specific  identification .
It also   finds  an array and  returns lots of  documents .
Query on Embedded or Nested  documents.
Query an  Array of  Embedded  documents.

**Update Operations:** Update is a  operation of modify  existing data documents  in  database 
   collection . It mostly like read operation  because it   also follow the query or specify 
   criteria  for updating data .
**For an example :
db.collection.updateOne ( query things are here )  [ It is use for updating one  document  from    collections ]
db.collection.updateMany ([ ])   [ It is use for  finding many documents from  collections ] 
  Example :
   db.products.updateMany(
   { price : { $ price :23 }} ;
   { $ set : { name : “ shoes  ”}}
    )**

 **Delete Operations:** It is a deleting operation it means it remove   document from database 
  permanently .  It also use the criteria  of specify and filtering method  for  exact identifying  the 
  document  in collection .  Delete operation  remove data in this way :
**db.collection.DeleteOne ( query things are here )   [ It is use for deleting  one  document from collections ]
db.collection.deleteMany  ([ ])   [ It is use for  deleting many documents from  collections ] 
   db .products.deleteMany (
    { name : “ shoes”} ,
  )**
    
**2. JWT :**  It’s  full  form is   JSON Web Tokens  . It is an internet process   for   securing  data or information between two parties. It holds  encoded JSON objects  and   signs using cryptographic algorithms  . It helps to validate the sender’s identification  and is made up of three parts which are separated by dots ( . )  and also  using base64 . In decoding we will get two JSON string :
Header and payload . [ Headers contain the type of token  like JWT in the case and singing algritom  and payload contains the claim ] 
Signature . [  It ensures that  the token hasn;t  been altered ]

**3.Mongoose:** Mongoose is an object Data Modeling library for MomgoDB and Node.js.It manages Data ,previous schema validation,and is used to translate between objects in code and the representation of those objects in MongoDB.MongoDb is schema -less Nosql document database.It means one can store JSON documents in it.The main reason of using Nosql is that it speeds up application development and reduces the complexity of developments.

**Ex- {
”Id”:1,
“email”:”JhonDoe@gmail.com”,
“phone”:2125444447
}
 {
”Id”:2,
“email”:”AlisaDoe@gmail.com”,
“phone”:21277444
}
 {
”Id”:3,
“email”:”ElexaDoe@gmail.com”,
“Phone”:245557
}**


**Benefits of using Mongoose:** They are-
Schemas: Mongoose defines a schema for data models so the documents follow a specific structure with predefined data types.

**Validation:** Mongoose has built-in validation for schema definitions.It saves us from writing a bunch of validation code that we have to write with the MongoDB driver.

**Instance Method:** It provides optional pre and post save operations for data models.It is easy to define hooks and custom functionality on reads and writes.It also organizes methods within schema definition.

**Returning result:** Mongoose makes it easier to return updated documents or query results.

**4.Express js:** Express is a minimal and flexible Node js web application framework that provides a set of features to develop web and mobile applications.It designed for building single-page,multi-page and hybrid web applications.It is the back end component of MERN stack which includes MongoDB for database and Node js for Javascript runtime environment.It makes it easier to organize our application’s functionality with middleware and routing.It also adds helpful utilities to Node js’s HTTP objects.It facilities the rendering of dynamic HTTP objects.It is an open source software distributed under the MIT license, which generally means that it’s free to develop and use.