Delete a filter from the database.
Permanently removes the specified filter. This operation cannot be undone.
Promise that resolves when the filter is deleted
import { State } from '@stencil/core';
import {
Filter,
PlatformServiceName,
SelectFilters,
} from '@limetech/lime-web-components';
class MyComponent {
@State()
@SelectFilters({ limetype: 'deal' })
private dealFilters: Filter[];
private async deleteFilter(id: string) {
const filter = this.dealFilters.find(
(candidate) => candidate.id === id
);
if (!filter) {
return;
}
const repository = platform.get(PlatformServiceName.FilterRepository);
await repository.delete(filter);
}
}
OptionalgetBetaGet a loaded filter by id.
Reads from the filters the repository already holds, so it does not
make a request. Returns undefined if no filter has the id, or if
the filters have not been loaded yet.
The id of the Filter
The Filter, or undefined if not found
import { PlatformServiceName } from '@limetech/lime-web-components';
const filters = platform.get(PlatformServiceName.FilterRepository);
const language = platform.get(PlatformServiceName.Application).getLanguage();
const filter = filters.getFilter?.('high_value_deals');
if (filter) {
console.log('Filter:', filter.name[language]);
}
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.
Promise that resolves when the filter is saved
import {
Filter,
Operator,
PlatformServiceName,
} from '@limetech/lime-web-components';
const filters = platform.get(PlatformServiceName.FilterRepository);
const application = platform.get(PlatformServiceName.Application);
const currentUser = application.getCurrentUser();
if (currentUser) {
const myDeals: Filter = {
id: 'my_deals',
limetype: 'deal',
name: { en: 'My Deals' },
filter: {
key: 'owner',
op: Operator.EQUALS,
exp: currentUser.id,
},
// Setting iduser keeps the filter private to this user.
iduser: currentUser.id,
};
await filters.save(myDeals);
}
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.
Function called with state updates (after map/filter applied)
Optionaloptions: StateOptionsOptional transformations and filters for the subscription
Unsubscribe function - call this to stop receiving updates
import { PlatformServiceName } from '@limetech/lime-web-components';
const repository = platform.get(PlatformServiceName.Application);
const logger = platform
.get(PlatformServiceName.Logger)
.createLogger('my-component');
// Basic subscription
const unsubscribeState = repository.subscribe((state) => {
logger.debug('State updated', { state });
});
// With transformations
const unsubscribeFullname = repository.subscribe(
(fullname) => logger.debug('User', { fullname }),
{ map: [(state) => state.currentUser?.fullname] }
);
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:
iduseris set)The repository extends StateRepository, enabling:
Example: Basic usage
See