skip to Main Content

How to use nested query using &or with &any in mongodb?

I'm learning mongoDB queries and have a problem given my collection looks like: "filename": "myfile.png", "updatedCoordinates": [ { "xmin": 537.640869140625, "xmax": 1049.36376953125, "ymin": 204.90736389160156, "ymax": 714.813720703125, "label": "LABEL_0", "status": "UNCHANGED" }, { "xmin": 76.68355560302734, "xmax": 544.8860473632812, "ymin": 151.90313720703125, "ymax": 807.1371459960938,…

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

Adding multiple fields to documents in mongodb using pymongo

I have a sample collection of documents in mongo db like below [{"name":"hans","age":30,"test":"pass","pre":"no","calc":"no"}, {"name":"abs","age":20,"test":"not_pass","pre":"yes","calc":"no"}, {"name":"cdf","age":40,"test":"pass"}, {"name":"cvf","age":30,"test":"not_pass","pre":"no","calc":"yes"}, {"name":"cdf","age":23,"test":"pass"}, {"name":"asd","age":35,"test":"not_pass"}] For some documents the fields pre and calc are not present. I want to add those two fields to the documents which…

VIEW QUESTION
Back To Top
Search