when using document's id as the only criteria in my query what's the difference between:
Board.only(:_id).find(params[:board_id])
and
Board.where(_id: params[:board_id]).only(:_id)
the only thing i've noticed is that printing the result as json when using where it encloses the result in square brackets
find returns one document.
where returns an array of documents that match the criteria.
To add to Kyle's answer:
If matching record is not found: find throws exception, where returns empty enumerable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With