Order

Sometimes you will need to get your rows from table in defined order. You can reach that using parameter order in query. Ordering can be done in two directions: ascending (ASC) and descending (DESC)

Say, to display price from bigger to less you can use such expression:

const query = {
  filter: {
    order: [
      { column: 'price', direction: 'DESC' }
    ]
  }
}

...or such one:

const query = {
  filter: {
    order: [
      { column: 3, direction: 'DESC' }
    ]
  }
}

...also such one:

const query = {
  filter: {
    order: [
      { column: { column: 'price' }, direction: 'DESC' }
    ]
  }
}

...and even such one:

const query = {
  filter: {
    order: [
      { column: { func: 'LOWER', args: [{ column: 'name' }] }, direction: 'DESC' }
    ]
  }
}

To use default ordering (ASC) you can:

...pass it explicitly:

const query = {
  filter: {
    order: [
      { column: 'price', direction: 'ASC' }
    ]
  }
}

...or omit direction parameter:

const query = {
  filter: {
    order: [
      { column: 'price' }
    ]
  }
}

...or just pass column name only:

const query = {
  filter: {
    order: 'price'
  }
}

...or pass FDB Column type

const query = {
  filter: {
    order: { column: 'price' }
  }
}

...also you can pass number of column instead of its name:

const query = {
  filter: {
    order: 3
  }
}

Simple rule: to make ordering by just one field use simple types like column name, number of column or FDB Column, to order by several fields - use an array of that values.

For more details see FDB Order By Clause type description.

Go to next chapter to understand how to use group parameter.




results matching ""

    No results matching ""