Is there a way to apply .order().descending to a postgres function, what is the syntax?
Closed this issue · 1 comments
calebcgates commented
I've without exaggeration spent the last few days digging through node-sql trying to answer this question.
What is the syntax to apply an ORDER BY .......... DESC
I would like to add DESC to the .order() found 4 lines below.
listing_processor.js
const functions = require('sql/lib/functions');
const listingListedDate = functions.getFunctions(`dash.listing_listed_date`);
query.order(listingListedDate(this._getTable()['data'])); //.descending?
Postgres Function dash.listing_listed_date
SELECT (data #>> '{listedDate}')::date
query_processor.js
const {listing} = require('../models');
_getTable() {
return listing;
}
models.js
function defineEntityTable(name){
return sql.define({
name: name,
columns: ['entity_id', 'last_update_on', 'data']
});
}
module.exports = {
listings: defineEntityTable('listings'),
};
calebcgates commented
I figured out the solution. It's pretty much what I expected.
return query.order(listingListedDate(this._getTable()[filterDataColumnName]).descending());