Oihana PHP Arango

descKey.php

Table of Contents

Functions

descKey()  : string
Returns the descending form of a sort key in the textual sort grammar (the same grammar consumed by `SortTrait::prepareSort` and the HTTP `?sort=` query parameter).

Functions

descKey()

Returns the descending form of a sort key in the textual sort grammar (the same grammar consumed by `SortTrait::prepareSort` and the HTTP `?sort=` query parameter).

descKey(string $key) : string

The descending form is the key prefixed with -. This helper centralizes that convention, avoiding magic-string concatenations like '-' . Prop::CREATED.

Do not confuse with aqlDesc(), which builds the AQL output token ("doc.name DESC") — this helper produces the HTTP/textual input token ("-name").

Parameters
$key : string

The sort field (typically a typed constant such as Prop::CREATED).

Tags
example
use App\Enums\Prop;
use oihana\arango\db\enums\AQL;
use oihana\arango\enums\Arango;

use function oihana\arango\helpers\descKey;
use function oihana\arango\helpers\sortKeys;

AQL::SORT_DEFAULT => descKey( Prop::CREATED ) ;                            // '-created'
Arango::SORT      => descKey( Prop::CREATED ) ;                            // '-created'
Arango::SORT      => sortKeys( descKey( Prop::CREATED ) , Prop::NAME ) ;   // '-created,name'
Arango::SORT      => sortKeys( descKey( Prop::CREATED ) , descKey( Prop::NAME ) ) ; // '-created,-name'
see
ascKey()

Ascending counterpart.

sortKeys()

Joins multiple sort tokens with a comma.

author

Marc Alcaraz

Return values
string

The descending sort token, prefixed with -.

On this page

Search results