Chandu yadav

Chandu yadav

810 Articles Published

Articles by Chandu yadav

Page 31 of 81

Access objects from the nested objects structure in MongoDB

Chandu yadav
Chandu yadav
Updated on 15-Mar-2026 771 Views

To access objects from nested objects structure in MongoDB, use dot notation to traverse through multiple levels of nested documents. This allows you to query and retrieve documents based on deeply nested field values. Syntax db.collection.find({ "parentObject.childObject.nestedField": "value" }); Create Sample Data Let us first create a collection with nested documents ? db.nestedObjectDemo.insertOne({ "Student": { "StudentDetails": { "StudentPersonalDetails": { ...

Read More

Drop all indexes from all the collections in a MongoDB database using the command line?

Chandu yadav
Chandu yadav
Updated on 15-Mar-2026 306 Views

To drop all indexes from all collections in a MongoDB database, use the dropIndexes command with the forEach method to iterate through all collections. This operation removes all custom indexes while preserving the mandatory _id index. Syntax db.getCollectionNames().forEach(function(collectionName) { db.runCommand({dropIndexes: collectionName, index: "*"}); }); Example Let's first check the current database and view existing indexes before dropping them ? db Test View Current Indexes Check existing indexes in a collection ? db.indexingDemo.getIndexes(); [ ...

Read More

Search for a text in MongoDBs Double Nested Array?

Chandu yadav
Chandu yadav
Updated on 15-Mar-2026 177 Views

To search for a text in MongoDB's double nested array, use dot notation to traverse through multiple array levels. The dot notation format is parentArray.childArray.fieldName to target specific fields deep within nested structures. Syntax db.collection.find({ "parentArray.childArray.fieldName": "searchValue" }); Sample Data Let us create a collection with double nested array documents ? db.doubleNestedArrayDemo.insertMany([ { "StudentId": "1000", "StudentName": "Larry", "StudentDetails": [ ...

Read More

How to get all the collections from all the MongoDB databases?

Chandu yadav
Chandu yadav
Updated on 15-Mar-2026 606 Views

To get all the collections from all MongoDB databases, you need to first retrieve all databases and then iterate through each database to get their collections. Syntax // Step 1: Get all databases switchDatabaseAdmin = db.getSiblingDB("admin"); allDatabaseName = switchDatabaseAdmin.runCommand({ "listDatabases": 1 }).databases; // Step 2: Iterate through databases to get collections allDatabaseName.forEach(function(databaseName) { db = db.getSiblingDB(databaseName.name); collectionName = db.getCollectionNames(); // Process collections as needed }); Method 1: Get All Database Names First, let us get all the databases using the admin ...

Read More

Search a string with special characters in a MongoDB document?

Chandu yadav
Chandu yadav
Updated on 15-Mar-2026 2K+ Views

To search a string with special characters in MongoDB document, you can use backslash (\) to escape the special character in a regular expression. Here, we have special character $ in our string. Syntax db.collection.find({ "fieldName": /.*\specialCharacter.*/i }); Sample Data Let us first create a collection with documents ? db.searchDocumentWithSpecialCharactersDemo.insertMany([ { "UserId": "Smith$John123", "UserFirstName": "John", "UserLastName": "Smith" ...

Read More

Get the array of _id in MongoDB?

Chandu yadav
Chandu yadav
Updated on 15-Mar-2026 830 Views

In MongoDB, the _id field is a mandatory field that acts as the primary key for each document. To retrieve documents by matching their _id values against an array of specific values, use the $in operator. Syntax db.collectionName.find({ _id: { $in: [value1, value2, value3, ...] } }); Create Sample Data db.selectInWhereIdDemo.insertMany([ {"_id": 23}, {"_id": 28}, {"_id": 45}, {"_id": 75}, {"_id": 85}, {"_id": 145} ]); { ...

Read More

HTML5 input type="file" accept="image/*" capture="camera" display as image rather than choose file button

Chandu yadav
Chandu yadav
Updated on 13-Mar-2026 504 Views

Use the JavaScript FileReader to allow users to choose an image file and display it as an image instead of showing the default file input button. This approach provides a better user experience by giving immediate visual feedback when an image is selected. The HTML5 input element with type="file", accept="image/*", and capture="camera" attributes allows users to select images from their device or capture photos directly from the camera on mobile devices. HTML Structure First, let's create the basic HTML structure with a file input and an image element − ...

Read More

How to reload the current page without losing any form data with HTML?

Chandu yadav
Chandu yadav
Updated on 13-Mar-2026 8K+ Views

The easiest way to reload the current page without losing form data is to use WebStorage, where you have persistent storage (localStorage) or session-based (sessionStorage) which remains in memory until your web browser is closed. Using localStorage to Preserve Form Data The key is to save form data before the page reloads and restore it after the page loads. Here's how to implement this solution − Step 1: Save Form Data Before Page Reload Use the beforeunload event to capture form data when the page is about to reload − window.onbeforeunload = function() { ...

Read More

Facing Problem in retrieving HTML5 video duration

Chandu yadav
Chandu yadav
Updated on 12-Mar-2026 515 Views

A common problem when working with HTML5 video is that the duration property returns NaN (Not a Number) when you try to access it before the browser has finished loading the video's metadata. This happens because the video file's metadata (which contains the duration, dimensions, etc.) is not available immediately after the page loads. Why Does video.duration Return NaN? The HTML5 element has a readyState attribute that indicates how much data the browser has loaded. It has values from 0 to 4 − 0 (HAVE_NOTHING) − No data available yet. 1 (HAVE_METADATA) − Metadata (duration, dimensions) is loaded. ...

Read More

Are new HTML5 elements like and useless?

Chandu yadav
Chandu yadav
Updated on 12-Mar-2026 198 Views

No, HTML5 semantic elements like and are not useless. They are extremely useful for screen readers and assistive technologies, helping visually impaired users navigate and understand the structure of your web page. They are also beneficial for eBook readers, search engines, and any tool that parses HTML for meaning. While you could use generic tags for everything, semantic elements convey the purpose of the content to both browsers and developers, making your code more readable and accessible. The Element The element represents a thematic grouping of content, typically with a heading. Use it to divide ...

Read More
Showing 301–310 of 810 articles
« Prev 1 29 30 31 32 33 81 Next »
Advertisements