File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -1371,6 +1371,29 @@ Mongoid also has some helpful methods on criteria.
13711371 Band.length
13721372 Band.where(name: "FKA Twigs").size
13731373
1374+ * - ``Criteria#pick``
1375+
1376+ *Get the values from one document for the provided fields.
1377+ Returns nil for unset fields and for non-existent fields.*
1378+
1379+ *This method accepts the dot notation, thus permitting referencing
1380+ fields in embedded associations.*
1381+
1382+ *This method respects :ref:`field aliases <field-aliases>`,
1383+ including those defined in embedded documents.*
1384+
1385+ -
1386+ .. code-block:: ruby
1387+
1388+ Band.all.pick(:name)
1389+
1390+ Band.all.pick('cities.name')
1391+
1392+ # Using the earlier definition of Manager,
1393+ # expands out to "managers.name" in the query:
1394+ Band.all.pick('managers.n')
1395+
1396+
13741397 * - ``Criteria#pluck``
13751398
13761399 *Get all the values for the provided field.
You can’t perform that action at this time.
0 commit comments