我的收藏集具有以下形式:
{ "_id" : ObjectId("5bc5dec478f5e2032d37e7c2"), "" : 1, "C_ID" : 1, "I_ID" : 7503672, "TIMESTAMP" : "2018-03-12"}
{ "_id" : ObjectId("4bc5dec478f5e2032e37e7c2"), "" : 1, "C_ID" : 1, "I_ID" : 6003672, "TIMESTAMP" : "2018-03-12"}
{ "_id" : ObjectId("2bc5dec478frgsg32d37e7c2"), "" : 1, "C_ID" : 1, "I_ID" : 9003672, "TIMESTAMP" : "2017-03-12"}
我想合并集合以获得此信息:
{ "_id" : ObjectId("8bc5dec478f5e2032d37e7c2"), "" : 1, "C_ID" : 1, "I_ID" : [7503672, 6003672], "TIMESTAMP" : "2018-03-12"}
{ "_id" : ObjectId("2bc5dec478frgsg32d37e7c2"), "" : 1, "C_ID" : 1, "I_ID" : 9003672, "TIMESTAMP" : "2017-03-12"}
直到现在,我一直尝试使用$ mergeObjects命令,但没有成功。
答案 0 :(得分:0)
此外,是否有任何查询可以提供以下输出:
{ "_id" : ObjectId("2bc5dec478frgsg32d37e7c2"), "" : 1, "C_ID" : 1, "DATE": [{"TIMESTAMP" : "2017-03-12", "I_ID" : 9003672}, {"TIMESTAMP" : "2018-03-12", "I_ID" : [7503672, 6003672]}]}