ここに私のコードです。は、MongoDBのサブフィールドの式を追加できません。
Cart
.aggregate()
.match(where)
.lookup({
from: "product_catelogs",
foreignField: "_id",
localField: "product_id",
as: "product"
})
.project({
product: {
$arrayElemAt: ["$product", 0]
},
"product.custom_field": {
$add: [1, 1]
},
product_quantity: 1,
product_variant: 1,
guest_token: 1,
user_id: 1,
product_id: 1,
})
ここでは、製品オブジェクトでカスタムフィールドを追加します。私はそうしようとしているときには、私はこの種のエラーを、直面しています
すでにフィールド全体に適用される表現 がありますので、製品のサブフィールドの式を追加することはできません
私を助けてください。
両方のスキーマのサンプルドキュメントを追加してください。 – notionquest