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

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -