![Introducing Enhanced Alert Actions and Triage Functionality](https://cdn.sanity.io/images/cgdhsj6q/production/fe71306d515f85de6139b46745ea7180362324f0-2530x946.png?w=800&fit=max&auto=format)
Product
Introducing Enhanced Alert Actions and Triage Functionality
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
@loopback/filter
Advanced tools
Readme
A set of utility typings and filter builders to aid in constructing LoopBack filters using the builder pattern.
This lightweight module provides strongly-typed typings and filter builders to intuitively construct LoopBack filters to be used against querying a LoopBack filter-compatible server over the network or within the server itself.
{% include note.html content="Already installed @loopback/repository
? Import from there instead. This package is meant for standalone use without @loopback/repository
." %}
npm install --save @loopback/filter
The WhereBuilder
is a builder specifically meant to construct the where
portion of the filter.
import {WhereBuilder} from '@loopback/filter';
const whereBuilder = new WhereBuilder();
const where = whereBuilder
.between('price', 99, 299)
.and({brand: 'LoopBack'}, {discount: {lt: 20}})
.or({instock: true})
.build();
The FilterBuilder
is a builder to construct the filter as a whole.
import {FilterBuilder} from '@loopback/filter';
const filterBuilder = new FilterBuilder();
const filter = filterBuilder
.fields('id', 'a', 'b')
.limit(10)
.offset(0)
.order(['a ASC', 'b DESC'])
.where({id: 1})
.build();
FilterBuilder.where()
also accepts an instance of WhereBuilder
.
const filterBuilder = new FilterBuilder();
const filter = filterBuilder
// ...
.where(where)
.build();
The FilterBuilder
and WhereBuilder
accept a model or any string-based key
objects' typing for strong typings:
/**
* Everything was imported from `@loopback/repository` as `@loopback/filter`
* is re-exported in that package.
**/
import {
FilterBuilder,
model,
property,
WhereBuilder,
} from '@loopback/repository';
@model()
class Todo extends Entity {
@property({id: true})
id: number;
@property()
title: string;
@property()
description: string;
@property()
priority: number;
}
const whereBuilder = new WhereBuilder<Todo>();
const where = whereBuilder.between('priority', 1, 3).build();
const filterBuilder = new FilterBuilder<Todo>();
const filter = filterBuilder
.fields('id', 'title')
.order(['title DESC'])
.where(where)
.build();
See the API docs for FilterBuilder and WhereBuilder for more details on the full API.
Run npm test
from the root folder.
See all contributors.
MIT
FAQs
Utility typings and filters for LoopBack filters.
The npm package @loopback/filter receives a total of 70,587 weekly downloads. As such, @loopback/filter popularity was classified as popular.
We found that @loopback/filter demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 10 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
Security News
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
Security News
OpenSSF is warning open source maintainers to stay vigilant against reputation farming on GitHub, where users artificially inflate their status by manipulating interactions on closed issues and PRs.