How would I .sort(random)?
SQL queries allow ORDER BY RAND() or ORDER BY RANDOM(), which is very useful when querying for 10 records at random.
Is this possible? Or would I have to retrieve them all and the randomly select from the returned array?
Waterline doesn't currently support this. If you are using a sql database you can use .query() and write a sql query that will return random values.
This would be a very cool addition... Hope this gets added soon...
I too would like to voice my support for this. Do we need to open a new feature request for this?
:+1: why is this ticket closed? This is a very important feature.
Hi @secrettriangle, I believe this was closed because this can be done with .query(). Do you know if other data stores (outside SQL ones) support sorting randomly?
@dmarcelino I don't know about other databases but I know PostgreSQL supports this, which is my use case.
The reason I ask is because if this is a PostgreSQL specific feature then it should be implemented in the sails-postgresql adapter. If such implementation requires waterline core changes then it's worth re-opening this.
I don't think it would be PostgreSQL specific, but might have to be implemented within Waterline itself if a database backend doesn't support it.
Any update?
It feels like waterline deprecates itself..
Most helpful comment
Any update?
It feels like waterline deprecates itself..