prorm API Reference
    Preparing search index...

    Function random

    • Create a random order expression SQL: ORDER BY RANDOM() (SQLite/PostgreSQL) or ORDER BY RAND() (MySQL)

      Returns OrderExpression

      // Random ordering (useful for sampling)
      User.findAll({ order: [random()] })
      // SQLite: ORDER BY RANDOM()
      // MySQL: ORDER BY RAND()
      // PostgreSQL: ORDER BY RANDOM()

      // With limit for random sample
      User.findAll({ order: [random()], limit: 5 })