DEV Community

Cover image for Some Node-Mongo Concept Intermediate Exploration
Showvro Roy
Showvro Roy

Posted on

Some Node-Mongo Concept Intermediate Exploration

JWT Token:

JWT stands for JSON Web Token. We use this for securely transmitting information between parties. Though it is digitally signed that’s why it is more than secure and this information can be verified and trusted also.

JWT authentication is a token-based stateless authentication mechanism. It is popularly used as a client-side-based stateless session, this means the server doesn’t have to completely rely on a database to save session information.
There are three parts of the jwt token header, payload, and signature.

Header
The header consists of two parts:
The signing algorithm being used
The type of token, which is in this case mostly “JWT”
Example:

{ "alg": "HS256", "typ": "JWT" }

Payload
The payload usually contains the claims and additional data like issuer, expiration time, and audience.

Signature
To create the signature part you have to take the encoded header, the encoded payload, a secret, the algorithm specified in the header, and sign that.

CRUD operation:

Create-Operation:
In MongoDB when we can add new documents to a collection. If the collection does not exist, create operations also create the collection. We can insert one or many documents

db.collection.insertOne()
db.collection.insertMany()

Read Operation:
Read operations retrieve documents from a collection; i.e. query a collection for documents. We can find the document using the read operation.

db.users.find({})

We can find multiple or single elements using the find operation.

Update Operations:
By using update operation we can update any document or replace any. We use this operation in MongoDB to update

db.collection.updateOne()
db.collection.updateMany()
db.collection.replaceOne()

Delete Operation:

When we need to delete any document from the database we use delete operation to delete that element.

db.collection.deleteOne()
db.collection.deleteMany()

Node js: Node.js is an open-source server environment. It is free and it runs on different browsers. It is also javascript.it uses asynchronous programming. It creates dynamic page content.

Explore Express:
Express.js is an open-source web application framework
We can build a web application quickly and easily. Express js uses javascript that’s why it’s become easier for programmers and developers to build web applications. It is important to learn javascript and HTML to be able to use Express.js.
Express.js supports javascript which is a widely used language that is very easy to learn and is also supported everywhere.
Features of Express.js:

  1. Faster Server side development, 2. Middleware, 3.Routing, 4. Templating, 5. Debugging

Top comments (0)