method Query.prototype.order
Query.prototype.order(
property: string,
options?: OrderOptions,
): this

Sort the results by a property name in ascending or descending order. By default, an ascending sort order will be used.

Examples

Example 1

const {Datastore} = require('@google-cloud/datastore');
const datastore = new Datastore();
const companyQuery = datastore.createQuery('Company');

// Sort by size ascendingly.
const companiesAscending = companyQuery.order('size');

// Sort by size descendingly.
const companiesDescending = companyQuery.order('size', {
  descending: true
});

Parameters

property: string

The property to order by.

optional
options: OrderOptions

Options object.

Return Type

this

See

Usage

import { Query } from ".";