adonisjs / lucid

AdonisJS SQL ORM. Supports PostgreSQL, MySQL, MSSQL, Redshift, SQLite and many more
https://lucid.adonisjs.com/
MIT License
1.02k stars 189 forks source link

feat(query_builder): add orderByRandom #1011

Open RomainLanz opened 3 months ago

RomainLanz commented 3 months ago

Hey there! 👋🏻

This PR adds a orderByRandom method to retrieve records in a random order. It defines the right keyword for each dialect.

The test may be flaky, I have set it up to run 3 times in case it fails.

A seed can be pass when using MySQL (same as Laravel implementation).