Skip to content

MultipleSystemQueryOptions

Niels Steenbeek edited this page Mar 24, 2020 · 2 revisions

MultipleSystemQueryOptions interface

The MultipleSystemQueryOptions interface wraps the complex, hard to read and hard to write query options $select, $filter, $expand, $orderby.

It uses Filter and extends SystemQueryOptions.

type Order = 'asc' | 'desc';
interface OrderBy {
    attribute: string;
    order?: Order;
}
export interface MultipleSystemQueryOptions extends SystemQueryOptions {
    filters?: Filter[];
    orders?: OrderBy[];
    top?: number;
}

Example Select

const options: MultipleSystemQueryOptions = {
          select: ['name']
      },
      accounts = await AccountService.retrieveMultipleRecords(options);
console.log(accounts[0].name);

Example Expand

const options: MultipleSystemQueryOptions = {
          select: ['name'],
          expands: [{
              attribute: 'owninguser',
              select: ['firstname']
          }]
      },
      accounts = await AccountService.retrieveMultipleRecords(options);
console.log(account[0].owninguser.firstname);

Example Top

const options: MultipleSystemQueryOptions = {
          select: ['name'],
          top: 5
      },
      accounts = await AccountService.retrieveMultipleRecords(options);
console.log(accounts.length); // <= 5

Example Orders

const options: MultipleSystemQueryOptions = {
          select: ['name'],
          orders: [{
              attribute: 'name',
              order: 'desc'
          }]
      },
      accounts = await AccountService.retrieveMultipleRecords(options);
console.log(accounts.length); // <= 5

Example Filters

See Filter examples.