Posts

Showing posts from July, 2025

Working With Date, Regex, And Arrays In MongoDB (GAURI GAWANDE)

Image
Da Dates: MongoDB uses the   Date  type to store date and time values. Dates are stored in  ISODate format , which includes both date and time. syntax: db.collection.insertOne({   name: "Gauri",   createdAt: new Date() }) db.collection.find({   createdAt: { $gte: ISODate("2025-01-01"), $lt: ISODate("2025-12-31") } })      Date operation: $gte ,   $lte ,   $eq   – Compare dates $dateToString   – Format date $subtract ,   $add  – Date arithmetic  example:  Imagine an application where you want to record every time a user logs in, including the exact time of the login. Inserting Login Records:  When a user successfully logs in, you would insert a document into a login history collection. The document would include the user's ID and a login_time field, set to the current date and time using MongoDB's...