skip to Main Content

How to filter mongodb collection using date field?

I have date string like this '2021-03-09' And my mongodb collection like this { "_id": { "$oid": "633aede250625c10dddfd57b" }, "title": "test 1", "description": "Hello World", "date": { "$date": "2021-03-09T18:30:00.000Z" }, "image": "fd16b297-9ad1-4e84-8c3e-715a33b351b3.png", "createdAt": { "$date": "2022-10-03T14:12:50.399Z" }, "updatedAt": { "$date":…

VIEW QUESTION

How to initiate mongodb replica set using nodejs

I'm running the following code for mongodb replica set initialization: try { const mongoClient: MongoClient = new MongoClient(process.env.MONGODB_URI || 'mongodb://mongodb:27017', {replicaSet: "rs0"}); const mongoDb: Db = new Db(mongoClient, "admin"); const response = await mongoDb.admin().command({ replSetInitiate: {} }, {}) } catch…

VIEW QUESTION

Mongodb – mongo query for a one-to-many collection where all records has to match the condition and get an unique record

Employee has multiple employeeActions, the employeeActions data looks like this: [ { "email": "[email protected]", "companyRegNo": 105, "event": { "created": ISODate("2022-09-16T06:42:04.387Z"), "desc": "COMPLETED_APPLICATIONS", "note": "Direct apply" } }, { "email": "[email protected]", "companyRegNo": 105, "event": { "created": ISODate("2022-09-20T06:42:42.761Z"), "desc": "ASKED_TO_REVIEW", } },…

VIEW QUESTION

Mongodb aggregation response

I have a Property controller : //Get Properties By Type const getPropertiesByType = async (req: Request, res: Response) => { const { cities, type } = req.query const citiesArr = typeof cities === 'string' ? cities.split(',') : [] try {…

VIEW QUESTION
Back To Top
Search