Skip to content

Tag: node.js

MongoDb update with ElemMatch

I have a collection that has document structure like following: Mongo PlayGround As you can see, each document has basicDetails object and a tasks array. Each task contains some properties of its own and a subtasks array. I want to update subtasks’s description from ABC to XYZ where root level id is 1, …

How can i calculate local time in node js

I want to do send a automated email from by backend with a date stored in my db. But the db consists of UTC date. I wanted to convert it to local time for the user sending the email. What i thought of was, i can send a offset while making the API call. i.e new Date().getTimezoneOffset() and i add

ReferenceError: require is not defined MongoDB

I’m trying to connect to my MongoDB database and I’m getting this error Answer You are attempting to use require() inside an ESM module (you can see the Object.loadESM in the call stack of the error) which tells us it’s an ESM module. You can’t use require() in that type of module. Ins…