How to use the @datorama/akita.QueryConfig function in @datorama/akita

To help you get started, we’ve selected a few @datorama/akita 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 datorama / akita / angular / playground / src / app / products / state / products.query.ts View on Github external
import { Injectable } from '@angular/core';
import { ProductsState, ProductsStore } from './products.store';
import { Product } from './products.model';
import { QueryConfig, QueryEntity } from '@datorama/akita';

@Injectable({ providedIn: 'root' })
@QueryConfig({ sortBy: 'price' })
export class ProductsQuery extends QueryEntity {
  constructor(protected store: ProductsStore) {
    super(store);
  }

  getProducts(term: string, sortBy: keyof Product) {
    return this.selectAll({
      sortBy,
      filterBy: entity => entity.title.toLowerCase().includes(term)
    });
  }
}