Skip to content

Commit 9cfad6d

Browse files
Copilotbohyunjung
authored andcommitted
Fix _id.bookId to bookId in reviews collection references
The reviews collection has bookId as a top-level field, not nested under _id. Fixed references in: - $group challenge (average book rating example) - $lookup challenge (JavaScript, mongosh, and Python examples)
1 parent 4279187 commit 9cfad6d

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

docs/50-aggregation/4-group.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ GROUP BY year;
140140
await reviews.aggregate([
141141
{
142142
$group: {
143-
_id: "$_id.bookId",
143+
_id: "$bookId",
144144
avgRating: { $avg: "$rating" }
145145
}
146146
}

docs/50-aggregation/5-lookup.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ The $lookup operation creates an array within each book document. Using $unwind
108108
{
109109
from: "reviews",
110110
localField: "_id",
111-
foreignField: "_id.bookId",
111+
foreignField: "bookId",
112112
as: "reviews"
113113
}
114114
}
@@ -125,7 +125,7 @@ The $lookup operation creates an array within each book document. Using $unwind
125125
{
126126
from: "reviews",
127127
localField: "_id",
128-
foreignField: "_id.bookId",
128+
foreignField: "bookId",
129129
as: "reviews"
130130
}
131131
}
@@ -157,7 +157,7 @@ The $lookup operation creates an array within each book document. Using $unwind
157157
{
158158
"from": "reviews",
159159
"localField": "_id",
160-
"foreignField": "_id.bookId",
160+
"foreignField": "bookId",
161161
"as": "reviews"
162162
}
163163
}

0 commit comments

Comments
 (0)