Lime Web Components API Documentation - v6.22.0
    Preparing search index...

    Interface FilterRepository

    Repository for managing saved filter definitions.

    FilterRepository provides methods to create, update, and delete Filter definitions. Filters are named, reusable query expressions that can be applied to limetypes to define subsets of objects (e.g., "My Active Deals", "High Priority Tickets").

    Filters can be:

    • System-wide (available to all users)
    • User-specific (private to a single user when iduser is set)
    • Referenced in InFilterExpressions for advanced queries

    The repository extends StateRepository, enabling:

    • Reactive subscriptions to filter changes
    • Automatic UI updates when filters are created or deleted
    • Integration with state decorators

    Basic usage

    const repo = platform.get(PlatformServiceName.FilterRepository);

    const filter: Filter = {
    id: 'high_value_deals',
    limetype: 'deal',
    name: { 'en': 'High Value Deals' },
    filter: {
    op: Operator.AND,
    exp: [
    { key: 'status', op: Operator.EQUALS, exp: 'active' },
    { key: 'value', op: Operator.GREATER_OR_EQUAL, exp: 100000 }
    ]
    }
    };

    await repo.save(filter);
    interface FilterRepository {
        delete(filter: Filter): Promise<void>;
        save(filter: Filter): Promise<void>;
        subscribe(
            callback: (...args: unknown[]) => void,
            options?: StateOptions,
        ): () => void;
    }

    Hierarchy (View Summary)

    Index

    Methods

    • Delete a filter from the database.

      Permanently removes the specified filter. This operation cannot be undone.

      Parameters

      Returns Promise<void>

      Promise that resolves when the filter is deleted

      Error if deletion fails due to permissions or other issues

      const repo = platform.get(PlatformServiceName.FilterRepository);
      await repo.delete(filter);
      • Filter for the filter structure
      • save to create or update a filter
    • Save a filter definition to the database.

      Creates a new filter or updates an existing one. The filter will be stored persistently and become available for use in queries and filter expressions.

      If a filter with the same id already exists, it will be updated with the new values. Otherwise, a new filter is created.

      Parameters

      Returns Promise<void>

      Promise that resolves when the filter is saved

      Error if save fails due to validation or permission issues

      const repo = platform.get(PlatformServiceName.FilterRepository);

      const filter: Filter = {
      id: 'my_deals',
      limetype: 'deal',
      name: { 'en': 'My Deals' },
      filter: { key: 'owner', op: Operator.EQUALS, exp: currentUserId }
      };

      await repo.save(filter);
    • Subscribe to state changes with optional transformation and filtering.

      The subscription will immediately invoke the callback with the current state (if any), then continue to call it whenever the state changes. The map and filter options allow you to transform and selectively receive updates.

      Parameters

      • callback: (...args: unknown[]) => void

        Function called with state updates (after map/filter applied)

      • Optionaloptions: StateOptions

        Optional transformations and filters for the subscription

      Returns () => void

      Unsubscribe function - call this to stop receiving updates

      • Map functions are applied sequentially to transform the state
      • Filter functions must all return true for the callback to be invoked
      • Functions in map/filter arrays are bound to the component instance
      • Always store and call the unsubscribe function when component is destroyed
      // Basic subscription
      const unsubscribe = repository.subscribe((state) => {
      console.log('State updated:', state);
      });

      // With transformations
      const unsubscribe = repository.subscribe(
      (userName) => console.log('User:', userName),
      { map: [(state) => state.user?.name] }
      );