Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private query(
localQueryExpression: QueryOrExpression,
remoteQueryExpression: QueryOrExpression,
include: string[][]
): QueryObservable {
const localQuery = buildQuery(localQueryExpression, {}, undefined, this.store.queryBuilder);
const remoteQuery = buildQuery(
remoteQueryExpression,
this.getRemoteQueryOptions(RequestType.OfflineFirst, include),
undefined,
this.store.queryBuilder
);
// initialize subject with current cached results
const changes$ = new BehaviorSubject>(this.getQueryResults(localQuery));
// listen for any changes resulting from the remote query
const handler = (transform: Transform, results: PatchResultData[]) => {
this.ngZone.run(() => {
if (this.isChangeApplicable(remoteQuery, transform, results, include)) {
changes$.next(this.getQueryResults(localQuery));
}
private query(
localQueryExpression: QueryOrExpression,
remoteQueryExpression: QueryOrExpression,
include: string[][]
): QueryObservable {
const localQuery = buildQuery(localQueryExpression, {}, undefined, this.store.queryBuilder);
const remoteQuery = buildQuery(
remoteQueryExpression,
this.getRemoteQueryOptions(RequestType.OfflineFirst, include),
undefined,
this.store.queryBuilder
);
// initialize subject with current cached results
const changes$ = new BehaviorSubject>(this.getQueryResults(localQuery));
// listen for any changes resulting from the remote query
const handler = (transform: Transform, results: PatchResultData[]) => {
this.ngZone.run(() => {
if (this.isChangeApplicable(remoteQuery, transform, results, include)) {
changes$.next(this.getQueryResults(localQuery));
}
});
query(
queryOrExpression: QueryOrExpression,
options?: object,
id?: string
): Model | Model[] | null {
const query = buildQuery(
queryOrExpression,
options,
id,
this._sourceCache.queryBuilder
);
const result = this._sourceCache.query(query);
if (result) {
return this.lookup(result);
} else {
return result;
}
}
async query(
queryOrExpression: QueryOrExpression,
options?: object,
id?: string
): Promise {
const query = buildQuery(
queryOrExpression,
options,
id,
this.source.queryBuilder
);
const result = await this.source.query(query);
return this.cache.lookup(result);
}
private onlineQuery(queryExpression: QueryOrExpression, include: string[][], persist: boolean): QueryObservable {
const query = buildQuery(
queryExpression,
this.getRemoteQueryOptions(persist ? RequestType.OnlinePersist : RequestType.OnlineOnly, include),
undefined,
this.store.queryBuilder
);
return from(this.storeQuery(query)).pipe(
map(r => new CacheQueryResults(this, this.convertResults(r), query.options.totalPagedCount))
);
}