How to use the @feathersjs/adapter-commons.sorter function in @feathersjs/adapter-commons

To help you get started, we’ve selected a few @feathersjs/adapter-commons examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github feathersjs-ecosystem / feathers-reactive / src / utils.js View on Github external
function makeSorter (query, options) {
  // The sort function (if $sort is set)
  const sorter = query.$sort ? createSorter(query.$sort) : createSorter({
    [options.idField]: 1
  });

  return function (result) {
    const isPaginated = !!result[options.dataField];
    let data = isPaginated ? result[options.dataField] : result;

    if (sorter) {
      data = data.sort(sorter);
    }

    const limit = typeof result.limit === 'number' ? result.limit : parseInt(query.$limit, 10);

    if (limit && !isNaN(limit) && limit !== -1) {
      data = data.slice(0, limit);
    }

@feathersjs/adapter-commons

Shared database adapter utility functions

MIT
Latest version published 17 days ago

Package Health Score

92 / 100
Full package analysis