Ohm, find all records from array of ids
-
02-06-2021 - |
Frage
I am looking for a way to find all Ohm affiliated objects with one query, by feeding it an array of attributes that are indexed. In Mongoid, this is done with something like:
Foo.any_in(:some_id => [list_of_ids])
ActiveRecord has the find_all
family of methods.
I essentially want to be able to pull N records from the data store without calling find() 30 times individually.
Lösung
You can pass find an array or list of IDs:
Foo.find(1,2,3) or Foo.find([1,2,3])
Andere Tipps
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow