mongodb-query

Reg: Data is not providing correct number in mongo aggregate function

﹥>﹥吖頭↗ 提交于 2020-12-23 18:32:10
问题 Using below query to get the output: db.action.aggregate([{ $match: { "$and": [{ "timeStamp": { "$gte": ISODate("2020-12-13T00:00:00.000-0400"), "$lt": ISODate("2020-12-15T23:59:59.000-0400") } }, { "functionStatus": "FMO_UVERSE_DTV" }] } }, { $group: { _id: { Dates: { $dateToString: { format: "%Y-%m-%d", date: "$timeStamp" } }, FS: "$functionStatus" }, JOBCOUNT: { $addToSet: "$jobId" } } }, { $project: { "_id": NumberInt(0), "Dates": "$_id.Dates", "FS": "$_id.FS", "Total_JOB_FMO_UVERSE_DTV":

Reg: Data is not providing correct number in mongo aggregate function

半世苍凉 提交于 2020-12-23 18:31:10
问题 Using below query to get the output: db.action.aggregate([{ $match: { "$and": [{ "timeStamp": { "$gte": ISODate("2020-12-13T00:00:00.000-0400"), "$lt": ISODate("2020-12-15T23:59:59.000-0400") } }, { "functionStatus": "FMO_UVERSE_DTV" }] } }, { $group: { _id: { Dates: { $dateToString: { format: "%Y-%m-%d", date: "$timeStamp" } }, FS: "$functionStatus" }, JOBCOUNT: { $addToSet: "$jobId" } } }, { $project: { "_id": NumberInt(0), "Dates": "$_id.Dates", "FS": "$_id.FS", "Total_JOB_FMO_UVERSE_DTV":

Reg: Data is not providing correct number in mongo aggregate function

别说谁变了你拦得住时间么 提交于 2020-12-23 18:31:05
问题 Using below query to get the output: db.action.aggregate([{ $match: { "$and": [{ "timeStamp": { "$gte": ISODate("2020-12-13T00:00:00.000-0400"), "$lt": ISODate("2020-12-15T23:59:59.000-0400") } }, { "functionStatus": "FMO_UVERSE_DTV" }] } }, { $group: { _id: { Dates: { $dateToString: { format: "%Y-%m-%d", date: "$timeStamp" } }, FS: "$functionStatus" }, JOBCOUNT: { $addToSet: "$jobId" } } }, { $project: { "_id": NumberInt(0), "Dates": "$_id.Dates", "FS": "$_id.FS", "Total_JOB_FMO_UVERSE_DTV":

MongoDB - $lookup in complex nested array

China☆狼群 提交于 2020-12-15 11:45:50
问题 I'm building a new LMS in mongodb and I have the following collections: Courses { "_id": ObjectId("5f6a6b159de1304fb885b194"), "title": "Course test", "sections": [ { "_id": ObjectId("5f6a6b159de1304fb885b195"), "title": "Section 1 - introduction", "order": 1, "modules": [ { "_id": ObjectId("5f6a6b159de1304fb885b196"), "module_FK_id": ObjectId("5f6a6b149de1304fb885b135"), "title": "Module 1", "order": 1 }, { "_id": ObjectId("5f6a6b159de1304fb885b198"), "module_FK_id": ObjectId(

PHP MongoDB aggregate $match and $group and $addToSet

我怕爱的太早我们不能终老 提交于 2020-12-14 23:37:15
问题 Having this document structure in MongoDB : { "_id":<MongoDBID>, "chatUser1ID": 2, "chatUser2ID": 3 } Now i want to get all chat partners from Mongo where the Chat Partner with the ID 2 is included in either "chatUser1" or "chatUser2". For that i want to use the $match and $group function. $chatUserID = $_POST["chatUserID"]; // 2 in my example $chatCursor = $chatCollection->aggregate([ [ '$match' => [ '$or' => [ ["chatUser1ID" => $chatUserID], ["chatUser2ID" => $chatUserID] ] ] ] ,[ '$group'

Mongodb aggregation: $reduce not working as expected

跟風遠走 提交于 2020-12-13 21:14:05
问题 I have a mongodb aggregation $reduce pipleine that is not working as expected. This is what I am trying to achieve. Basically I am trying to get the object with the highest value in a given property. In some objects $reduce returns the wrong object in others it returns null , meaning no object satisfied the condition. My code has the group stage and other stage that produce the variable used in the $reduce stage. Are there any known preceding stages in the aggregation pipeline that might be

Mongodb aggregation: $reduce not working as expected

拟墨画扇 提交于 2020-12-13 21:05:06
问题 I have a mongodb aggregation $reduce pipleine that is not working as expected. This is what I am trying to achieve. Basically I am trying to get the object with the highest value in a given property. In some objects $reduce returns the wrong object in others it returns null , meaning no object satisfied the condition. My code has the group stage and other stage that produce the variable used in the $reduce stage. Are there any known preceding stages in the aggregation pipeline that might be

Mongodb aggregation: $reduce not working as expected

老子叫甜甜 提交于 2020-12-13 21:02:08
问题 I have a mongodb aggregation $reduce pipleine that is not working as expected. This is what I am trying to achieve. Basically I am trying to get the object with the highest value in a given property. In some objects $reduce returns the wrong object in others it returns null , meaning no object satisfied the condition. My code has the group stage and other stage that produce the variable used in the $reduce stage. Are there any known preceding stages in the aggregation pipeline that might be

Mongodb aggregation: $reduce not working as expected

放肆的年华 提交于 2020-12-13 21:01:12
问题 I have a mongodb aggregation $reduce pipleine that is not working as expected. This is what I am trying to achieve. Basically I am trying to get the object with the highest value in a given property. In some objects $reduce returns the wrong object in others it returns null , meaning no object satisfied the condition. My code has the group stage and other stage that produce the variable used in the $reduce stage. Are there any known preceding stages in the aggregation pipeline that might be

MongoDB - Find documents matching certain condition for unknown field keys

我们两清 提交于 2020-12-12 12:14:38
问题 How can I query a MongoDB collection to find documents with a structure as below? The documents have a field called thing which is a subdocument, and the keys for this field are a form of ID number which will generally not be known by the person writing the query (making dot notation difficult and I assume impossible). { "_id" : 3, "_id2" : 234, "thing": { "2340945683": {"attribute1": "typeA", "attribute2": "typeB", "attribute3": "typeA" }, "349687346": {"attribute1": "typeC", "attribute2":