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.
Example 1
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 });