skip to Main Content

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

Simple MongoDB Aggregation

I'm a bit confused on how to group using aggregation but still be able to extract specific values from arrays: db.collection.aggregate([ { "$unwind": f"${stat_type}" }, { "$group": { "_id": "$userId", "value" : { "$max" : f"${stat_type}.stat_value" }, "character" : f"${stat_type}.character_name",…

VIEW QUESTION

Mongodb – Aggregation $match within a $sum

I was wondering if it was possible to somehow use the $match operator within the $sum function for aggregation. { "$unwind": "$info.avatarInfoList" }, { "$unwind": "$info.avatarInfoList.equipList" }, { "$unwind": "$info.avatarInfoList.equipList.flat.reliquarySubstats" }, { "$project": { "name" : "$name", "character" : "$info.avatarInfoList.avatarId",…

VIEW QUESTION

How to merge two mongodb query into one

I have two mongodb aggregate query as shown below. The below query gives me the count of total failed and the sectionType db.Departments.aggregate([ { $match: {$and: [{"subject.failed": {$eq: 'true'}}, {"section": {$eq: 'A'}}]} }, { $group: { _id: {"sectionType": "$sectionType"}, "COUNT(*)":…

VIEW QUESTION
Back To Top
Search