How to use the @orbit/data.buildQuery function in @orbit/data

To help you get started, we’ve selected a few @orbit/data examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sillsdev / web-languageforge / src / SIL.XForge.Scripture / ClientApp / src / xforge-common / json-api.service.ts View on Github external
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));
        }
github sillsdev / web-languageforge / src / SIL.XForge.Scripture / ClientApp / src / xforge-common / json-api.service.ts View on Github external
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));
        }
      });
github orbitjs / ember-orbit / addon / -private / cache.ts View on Github external
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;
    }
  }
github orbitjs / ember-orbit / addon / -private / store.ts View on Github external
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);
  }
github sillsdev / web-languageforge / src / SIL.XForge.Scripture / ClientApp / src / xforge-common / json-api.service.ts View on Github external
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))
    );
  }