-
Type: Bug
-
Resolution: Duplicate
-
Priority: Major - P3
-
None
-
Affects Version/s: 7.0.5
-
Component/s: Query
-
None
-
Environment:OSX 10.13.6
Mongo: db version v3.6.2
mongo gem 2.10.2
I searched the docs and there is no mention of order_by or sort (except default sort by _id).
https://docs.mongodb.com/mongoid/current/tutorials/mongoid-queries/#id1
Is it possible that Mongoid no longer supports order_by?
I found this documentation but not sure if is applicable:
https://www.rubydoc.info/github/mongoid/origin/Origin%2FOptional:order_by
Putting docs aside, it seems that order_by does not work.
ap Category.order_by(created_at: :asc).pluck(:name, :created_at)
[
{{ [0] [}}
{{ [0] "computers",}}
{{ [1] 2019-10-09 02:43:35 UTC}}
{{ ],}}
{{ [1] [}}
{{ [0] "cosmetics",}}
{{ [1] 2019-11-09 18:43:26 UTC}}
{{ ],}}
{{ [2] [}}
{{ [0] "electronics",}}
{{ [1] 2019-10-09 02:43:35 UTC}}
{{ ],}}
- duplicates
-
MONGOID-4818 Document order in default scope taking precedence over order in query
- Closed
- related to
-
MONGOID-4800 Document order_by in Mongoid
- Closed