我的mongodb中的JSON数据,包含集合名称和查询
db.getCollection('UserCompanyDetails').find({})
示例输出:
{
"_id" : ObjectId("5885d3d99aa060de0b8b4569"),
"CompanyEmailId" : "punnamadhu@gmail.com",
"CompanyPassword" : "1eb1f47fc0e5603966a6d2e7142724f5",
"CompanyContact" : "9666999011",
"CompanyName" : "Madhu",
"ContactPersonName" : "Madhu",
"CompanyAddress" : "hyderabad",
"CompanyState" : "",
"CompanyCountry" : "",
"CompanySpecilizations" : [
"5869edb837478d6018b7dfac",
"5869edb937478d6018b7dfaf"
],
"CompanyStatus" : NumberLong(1),
"CompanyOtpStatus" : NumberLong(1)
}
另一个名为
的集合db.getCollection('UserIdOtp').find({})
示例输出:
/* 1 */
{
"_id" : ObjectId("587cc76a9aa060a5138b456b"),
"otp" : "946170",
"userID" : "587cc76a9aa060a5138b456a",
"otpStatus" : NumberLong(0)
}
/* 2 */
{
"_id" : ObjectId("587cc7f19aa0600e068b456d"),
"otp" : "261743",
"userID" : "5885d3d99aa060de0b8b4569",
"otpStatus" : NumberLong(0)
}
/* 3 */
{
"_id" : ObjectId("587cc9349aa06082288b456b"),
"otp" : "197305",
"userID" : "587cc7f19aa0600e068b456c",
"otpStatus" : NumberLong(0)
}
所以我想用聚合来合并这两个集合,我该怎么做呢?