question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

I’m trying to get random product rows from products table and limit the random rows retrieved to 16 rows. I can’t seem to find the operators to handle this case. I also checked StackOverFlow and couldn’t find what I was looking for. I found limit in the docs but is that best to be used or the $lt?

DB.models.products.findAll({
    limit: args.quantity,
    order: [
      [Sequelize.fn('RAND', '')]
    ]
})

This peice of code returns the following errors: "function rand(unknown) does not exist"

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:2
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

12reactions
harrisonlocommented, Sep 8, 2021

The above answer still gives me an error

"function rand() does not exist"

UPDATE:

There’s a typo here, it’s ‘RANDOM’

order: [ [ Sequelize.fn('RANDOM') ] ]

2reactions
sushantdhimancommented, Oct 16, 2016

@harrison0723 MySQL have RAND() and Postgres have RANDOM() , different names for different database for same task 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Random Operator | Rainbow Six: Siege
Make the game more challenging by using a randomly slected operator with random loadout!
Read more >
Rainbow Six: Siege - Random Operator - Orcicorn
Can't decide who to play? Let a computer decide which Operator you're playing in Rainbow Six: Siege (Mobile Friendly)
Read more >
Random Operators - American Mathematical Society
Random operators : disorder effects on quantum spectra and dynamics / Michael ... book starts with some of the core topics of random...
Read more >
Random Operator - an overview | ScienceDirect Topics
Let T be a random operator from Ω × X into Y. An equation of the type T[·,x(·)] = y(·) where y is...
Read more >
R6 Operator Randomizer - Apps on Google Play
this is an app that is simple to use and very fun. it gives you the ability to get an random operator selected...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found