mongoid3 - Best strategy for picking random documents in Mongoid -
i need pick random document out of database , wanted know better strategy ruby shuffle method less resource intensive large databases.
add "random" field , have default value set proc returns random float. whenever need pull random document, type model.where(:random.gt => rand).first
Comments
Post a Comment