You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
var scores = Bookshelf.knex('audition_vote').sum('voting_power as score').groupBy('audition_id')
and i want to wrap this query like:
var topScores = Bookshelf.knex.distinct('score').from(function() {
// This works but i want to use "scores" variable
this.sum('voting_power as score').from('audition_vote').groupBy('audition_id').as('scores');
});
console.log(topScores.toString()) prints
select distinct `score` from (select sum(`voting_power`) as `score` from `audition_vote` group by `audition_id`) as `scores
How to use the variable "scores" inside from() ????
The text was updated successfully, but these errors were encountered:
varscores=Bookshelf.knex('audition_vote').sum('voting_power as score').groupBy('audition_id').as('scores');vartopScores=Bookshelf.knex.distinct('score').from(scores.clone());
The .as is ignored unless it's within a subquery, and the clone is only necessary if you're mutating the scores query elsewhere.
Or you could do:
varscores=Bookshelf.knex('audition_vote').sum('voting_power as score').groupBy('audition_id');vartopScores=Bookshelf.knex.distinct('score').from(scores.clone().as('scores'));
Hi!
I have this query:
and i want to wrap this query like:
console.log(topScores.toString()) prints
How to use the variable "scores" inside from() ????
The text was updated successfully, but these errors were encountered: