我有以下查询,它在MONGOSH上执行得很好:
db.getCollection("user_products").aggregate( [
{
$lookup:
{
from: "users",
localField: "user_id",
foreignField: "_id",
as: "user"
}
},
{
$lookup:
{
from: "products",
localField: "product_id",
foreignField: "_id",
as: "product"
}
},
{
$unwind: "$product"
},
{
$unwind: "$user"
},
{
"$project": {
"_id": 1,
"creation_date": 1,
"support_all_payment": 1,
"payment": 1,
"imported": 1,
"name": "$user.name",
"country_code": "$user.country_code",
"phone_number": "$user.phone_number",
"wallet_credit": "$user.wallet_credit",
"score": "$user.score",
"birthday": "$user.birthday",
"bio": "$user.bio",
"education": "$user.education",
"email": "$user.email",
"job": "$user.job",
"major": "$user.major",
"sex": "$user.sex",
"have_you_attended_courses_on_personal_and_organizational_success": "$user.have_you_attended_courses_on_personal_and_organizational_success",
"what_books_have_you_read_about_growth_and_development_and_success": "$user.what_books_have_you_read_about_growth_and_development_and_success",
"which_of_the_success_professors_are_you_interested_in_and_what_is_the_reason_for_your_interest": "$user.which_of_the_success_professors_are_you_interested_in_and_what_is_the_reason_for_your_interest",
"city": "$user.city",
"state": "$user.state",
"favorites": "$user.favorites",
"fixed_number": "$user.fixed_number",
"show": "$product.show",
"title": "$product.title",
"type": "$product.type",
"little_description": "$product.little_description",
"description": "$product.description",
"price": "$product.price",
"support_price": "$product.support_price",
"discount": "$product.discount",
}
}
] )
由于我需要导出结果,并且我使用MongoDB Compass,所以我需要将上面的查询转换为JSON格式
{}
。
我厌倦了一些在线工具,但没有成功,知道如何将其转换为JSON吗?