Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Articles on Trending Technologies
Technical articles with clear explanations and examples
Get names of all keys in the MongoDB collection?
Since MongoDB documents can have different structures (no fixed schema), getting all key names requires iterating over documents. There are multiple approaches depending on whether you need keys from one document or all documents. Method 1: Using JavaScript Loop (Single Document) Use findOne() to get a document and loop through its keys ? var doc = db.studentGetKeysDemo.findOne(); for (var key in doc) { print(key); } Sample Data db.studentGetKeysDemo.insertOne({ "StudentId": 1, "StudentName": "Larry", "StudentAge": 23, ...
Read MoreHow to query MongoDB with LIKE?
MongoDB does not have a LIKE operator like SQL. Instead, use regular expressions (regex) or the $regex operator for pattern matching. Syntax // Using regex literal (equivalent to SQL LIKE '%value%') db.collection.find({"field": /.*value.*/}) // Using $regex operator db.collection.find({"field": {$regex: "value", $options: "i"}}) Create Sample Data db.employee.insertMany([ {"EmployeeName": "John", "EmployeeSalary": 450000}, {"EmployeeName": "Carol", "EmployeeSalary": 150000}, {"EmployeeName": "James", "EmployeeSalary": 550000}, {"EmployeeName": "Jace", "EmployeeSalary": 670000}, {"EmployeeName": "Larry", "EmployeeSalary": 1000000} ]); Query with "like" ...
Read MoreFind objects between two dates in MongoDB?
Use the $gte (greater than or equal) and $lt (less than) operators with ISODate() to find documents between two dates in MongoDB. Create Sample Data db.order.insertMany([ {"OrderId": 1, "OrderAddress": "US", "OrderDateTime": ISODate("2019-02-19")}, {"OrderId": 2, "OrderAddress": "UK", "OrderDateTime": ISODate("2019-02-26")}, {"OrderId": 3, "OrderAddress": "IN", "OrderDateTime": ISODate("2019-03-05")} ]); Find Between Two Dates Find orders between Feb 10 and Feb 21 ? db.order.find({ "OrderDateTime": { $gte: ISODate("2019-02-10"), ...
Read MoreUpdate MongoDB field using value of another field?
In MongoDB, you can update a field using the value of another field in the same document. There are two main approaches − using the aggregation pipeline with $set (MongoDB 4.2+) or using $addFields with $out for writing results to a collection. Method 1: Update with Aggregation Pipeline (MongoDB 4.2+) Use updateMany() with an aggregation pipeline to set a field based on other fields ? // Create sample data db.studentInformation.insertOne({ "StudentFirstName": "Carol", "StudentLastName": "Taylor" }); // Update: create FullName from FirstName + LastName db.studentInformation.updateMany( ...
Read MoreRetrieve only the queried element in an object array in MongoDB collection?
To retrieve only the matching element from an object array in MongoDB, use the $elemMatch projection operator or the $ positional projection operator. Both return only the first array element that matches the query condition. Create Sample Data db.objectArray.insertMany([ { "Persons": [ {"PersonName": "Adam", "PersonSalary": 25000}, {"PersonName": "Larry", "PersonSalary": 27000} ] ...
Read MoreOpen Source Databases
Open source databases have publicly available source code that anyone can view, study, or modify. They can be relational (SQL) or non-relational (NoSQL), and they significantly reduce database costs compared to proprietary solutions. Why Use Open Source Databases? Database licensing is a major software expense for companies. Open source databases offer a cost-effective alternative − free to use, with community support, and no vendor lock-in. Many also offer commercial support tiers for enterprise needs. Popular Open Source Databases Database Type Key Feature MySQL Relational (SQL) Most widely used open source DB; community ...
Read MoreHow to prepare a Python date object to be inserted into MongoDB?
MongoDB stores dates in ISODate format. PyMongo (the official MongoDB driver for Python) directly supports Python's datetime.datetime objects, which are automatically converted to ISODate when inserted. There are three common ways to prepare date objects for MongoDB. Method 1: Current UTC Timestamp Use datetime.datetime.utcnow() to insert the current UTC time ? import datetime from pymongo import MongoClient client = MongoClient() db = client.test_database result = db.objects.insert_one({"last_modified": datetime.datetime.utcnow()}) print("Date Object inserted") Date Object inserted Method 2: Specific Date Use datetime.datetime(year, month, day, hour, minute) for a fixed date ? ...
Read MoreDifference Between RDBMS and Hadoop
RDBMS stores structured data in tables with ACID compliance using SQL. Hadoop is an open-source framework for distributed storage and processing of large-scale structured and unstructured data using HDFS and MapReduce. What is RDBMS? RDBMS (Relational Database Management System) stores data in tables with rows and columns, following ACID properties (Atomicity, Consistency, Isolation, Durability). It is designed for fast storage and retrieval of structured data using SQL. Examples: Oracle, MySQL, PostgreSQL. What is Hadoop? Hadoop is an open-source framework for running distributed applications and storing large-scale data. It handles structured, semi-structured, and unstructured data with high ...
Read MoreHow To Configure PostgreSQL 12 Streaming Replication in CentOS 8?
PostgreSQL Streaming Replication continuously streams Write-Ahead Log (WAL) data from a primary (master) node to standby (slave) nodes, creating near-real-time database copies for high availability and fault tolerance. Master Read/Write WAL Slave 1 Slave 2 Read-only Read-only Master Node Configuration 1. Enable WAL Archiving Edit ...
Read MoreHow to Download and Install PostgreSQL on Windows?
PostgreSQL is a powerful, open-source relational database system used for enterprise applications. This guide covers downloading, installing, configuring, and testing PostgreSQL on Windows. Downloading PostgreSQL Go to postgresql.org/download/windows Click Download the installer (EnterpriseDB graphical installer) Select the latest version for your OS (64-bit recommended) Download will begin automatically Installing PostgreSQL Run the downloaded installer and follow these steps − Step 1: Welcome screen → Click Next Step 2: Select components (keep all selected: PostgreSQL Server, pgAdmin, Command Line Tools, Stack Builder) Step 3: Choose installation directory (default recommended) Step 4: Choose data ...
Read More