私は次のクエリ出力値にMongoDB
db.mycollection.aggregate({$sample: {size: 2}}, {$project: {"_id": 1,"text": 1}})
を行うときに、私はこの
"123", "some writing"
"456", "some more writing"
のようなものであることを私の出力を探しています以下のような出力
"_id" : "123", "text" : "some writing"
"_id" : "456", "text" : "some more writing"
を取得
質問:
関連するキーなしで値("123"
と"some writing"
)を出力する方法はありますか? ("_id":
と"text":
)
{$ replaceRoot:{newRoot:{$ arrayToObject:{"$ zip":{"inputs": "入力"を追加することができます。 [["$ _id"]、["$ text"]]}}}} '応答をフォーマットするサンプルステージの後。 – Veeram