File tree Expand file tree Collapse file tree 1 file changed +28
-1
lines changed Expand file tree Collapse file tree 1 file changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -305,7 +305,7 @@ Mongoid 7 behavior:
305
305
306
306
307
307
``#pluck`` on Embedded Criteria Returns ``nil`` Values
308
- ------------------------------------------------
308
+ ------------------------------------------------------
309
309
310
310
Mongoid 8 fixes a bug where calling ``#pluck`` on a Mongoid::Criteria
311
311
for embedded documents discarded nil values. This behavior was
@@ -573,3 +573,30 @@ Calling ``tally`` on the age field yields the following:
573
573
574
574
The ``tally`` method accepts the dot notation and field aliases. It also
575
575
allows for tallying localized fields.
576
+
577
+
578
+ ``find`` delegates to ``Enumerable#find`` when given a block
579
+ ------------------------------------------------------------
580
+
581
+ When given a block, without ``_id`` arguments, ``find`` delegates to
582
+ ``Enumerable#find``. Consider the following model:
583
+
584
+ .. code::
585
+
586
+ class Band
587
+ include Mongoid::Document
588
+ field :name, type: String
589
+ end
590
+
591
+ Band.create!(name: "Depeche Mode")
592
+ Band.create!(name: "The Rolling Stones")
593
+
594
+ Calling ``find`` with a block returns the first document for which the block
595
+ returns ``true``:
596
+
597
+ .. code::
598
+
599
+ Band.find do |b|
600
+ b.name == "Depeche Mode"
601
+ end
602
+ # => #<Band _id: 62c58e383282a4cbe82bd74b, name: "Depeche Mode">
You can’t perform that action at this time.
0 commit comments