Queries with SxcApp.query<T>(...)
Use SxcApp.query<T>(queryName) to run a configured 2sxc Query.
The returned service supports:
getAll(params?)to return the object containing all streams.getStream(streamName, params?)to return one stream.getStreams(streamNames, params?)to request selected streams.- Optional POST data as the final argument of each method.
Example
import { SxcApp } from '@2sic.com/sxc-angular';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
@Injectable({ providedIn: 'any' })
export class TeamService {
readonly team$: Observable<Person[]>;
constructor(app: SxcApp) {
this.team$ = app
.query<Person[]>('BusinessUnitTeam')
.getStream('Default', { bu: 'Web' });
}
}
To retrieve all query streams as one typed object:
interface TeamQueryResult {
Default: Person[];
BusinessUnits: BusinessUnit[];
}
const result$ = app
.query<TeamQueryResult>('BusinessUnitTeam')
.getAll({ bu: 'Web' });
The old Data.query$<T>(...) shortcut is not part of v22. The result of the new methods is still an RxJS observable.