-
Type:
Bug
-
Resolution: Gone away
-
Priority:
Major - P3
-
None
-
Affects Version/s: 7.0.5
-
Component/s: Associations, Query
-
None
-
None
-
None
-
None
-
None
-
None
-
None
-
None
Let's say you have a User document, and embedded inside of it a posts document order by title:
```
embeds_many :posts, order: :title.asc
```
If you query a user's post: `User.first.posts`, the posts are returned in proper order.
However, if you use an aggregation $match:
```
User.collection.aggregate([
} ])
```
The posts are returned in a different order than by title. To order the posts again you have to use the aggregation pipeline:
```
{ "$unwind" => "$posts" }, {
"$sort" =>
},
```
Why is the aggregation pipeline not preserving the order of embedded documents??