Fetching Records From MongoDB - NodeJS in Hindi 88


00:00 Intro 1:27 fetching records 03:01 What is Cursor? code: In this video we will learn how to fetch records from MongoDB collections What is a cursor object in MongoDB? How can we display the data in our node js template? In MongoDB a cursor is a pointer or iterator used to retrieve query results from the database.
When you execute a query in MongoDB it returns a cursor object that allows you to traverse the result set and retrieve documents from the collection. Here are a few key points about cursors in MongoDB: Lazy Evaluation: MongoDB cursors use lazy evaluation which means that the query results are not fetched all at once.
Instead the documents are fetched as you iterate through the cursor improving memory efficiency for large result sets. Iteration: You can iterate through the cursor using methods like next forEach or by using a loop construct.
Each iteration returns the next document from the result set until there are no more documents. Batching: The cursor retrieves documents from the server in batches.
By default the batch size is set by the MongoDB server but you can also specify a custom batch size to control the number of documents fetched per batch. Methods and Properties: The cursor object provides various methods and properties to work with the result set.
Some commonly used methods include toArray returns all documents as an array forEach iterates over each document and count returns the count of documents matching the query.
Additionally properties like hasNext checks if there are more documents and limit limits the number of documents to fetch can be used to control the cursor behavior. Tailable Cursors: MongoDB also supports tailable cursors which allow you to continuously fetch new documents as they are inserted into a capped collection.
Tailable cursors are commonly used for scenarios like log tailing or real-time event processing. By using cursors you can efficiently retrieve and process query results from MongoDB enabling you to work with large data sets without consuming excessive memory.
Cursors provide flexibility in navigating the result set and fetching documents on-demand as you need them. nodejstutorial nodejs nodejshindi javascript mvc node.js mongodb mongodbtutorialforbeginners mongodbtutorial node js tutorial

Источник: rutube.ru

Сообщение от Commenton: Необходимо стартовать сессию