I have the following query db in mongodb that returns exactly what I need:
db.collection.find({field1: 2801394}, {name: 1, field2: 1, _id: 1, "field3.2801394": 1})
Note field 3 is a hash, and the key used here is the same as for field1 by the value in field 1.
How can I convert this query to mongoid? There are two main issues here, and I can't find anything online for either one individually:
- I can't figure out the syntax for both plucking two fields at once
- I can't find the syntax for plucking a nested field.
Thanks!
#distinct
instead of#pluck
See that question for more: https://mcmap.net/q/2029899/-pluck-vs-distinct-in-mongoid-db-which-is-faster/2047418 – Suitcase