node.jskaltura

OrderBy filter not working for kaltura media listing api using


I am fetching media list from Kaltura which is working perfectly fine using Kaltura-client. But when trying to filter it using order by, it is not working as expected (Returning the same list).

const Promise = require('bluebird');
const kaltura = require('kaltura-client/KalturaClient');

exports.getMediaList = Promise.method((client, pager) => {

  return new Promise(function (resolve, reject) {

    return kaltura.services.media.listAction({ orderBy: 'CREATE_DATE_DESC'}, pager).execute(client).then((response) => {
      resolve(response.objects);
    }, (error) => {
      reject(error);
    })
  });
});

Solution

  • Here, If we pass '-createdAt' for orderBy, We can get media in recent list

    const Promise = require('bluebird');
    const kaltura = require('kaltura-client/KalturaClient');
    
    exports.getMediaList = Promise.method((client, pager) => {
    
      return new Promise(function (resolve, reject) {
    
        return kaltura.services.media.listAction({ orderBy: '-createdAt'}, pager).execute(client).then((response) => {
          resolve(response.objects);
        }, (error) => {
          reject(error);
        })
      });
    });