-
Notifications
You must be signed in to change notification settings - Fork 1
MultipleSystemQueryOptions
Niels Steenbeek edited this page Mar 24, 2020
·
2 revisions
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;
}
const options: MultipleSystemQueryOptions = {
select: ['name']
},
accounts = await AccountService.retrieveMultipleRecords(options);
console.log(accounts[0].name);
const options: MultipleSystemQueryOptions = {
select: ['name'],
expands: [{
attribute: 'owninguser',
select: ['firstname']
}]
},
accounts = await AccountService.retrieveMultipleRecords(options);
console.log(account[0].owninguser.firstname);
const options: MultipleSystemQueryOptions = {
select: ['name'],
top: 5
},
accounts = await AccountService.retrieveMultipleRecords(options);
console.log(accounts.length); // <= 5
const options: MultipleSystemQueryOptions = {
select: ['name'],
orders: [{
attribute: 'name',
order: 'desc'
}]
},
accounts = await AccountService.retrieveMultipleRecords(options);
console.log(accounts.length); // <= 5
See Filter examples.