Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
@dialexa/pleco
Advanced tools
The pleco libraries provide helpful utilities to make querying on the database layer easier. The library provides typescript types, GraphQL types, and Joi validation types for filtering, sorting, and paging as well as functions to perform those operations.
yarn add @dialexa/pleco
or
npm install @dialexa/pleco
yarn add @dialexa/pleco-knex
or
npm install @dialexa/pleco-knex
yarn add @dialexa/pleco-graphql
or
npm install @dialexa/pleco-graphql
yarn add @dialexa/pleco-joi
or
npm install @dialexa/pleco-joi
Refer to each querybuilder implementation's package to view the usage for each function.
Before we dive into the functions that are provided, pleco
has some prerequisites
that must be met for the functions to work. Because of the nature of supporting multiple query builders,
extensions must be used to properly call the methods. To convert your query builder to the generic
query builder that pleco
uses, refer to the extension library documentation.
For more information about the generic query builder, refer to the Extensions section
Note that all of the examples in this README are using the pleco-knex
extension.
This function forms the filter query. The arguments are
args
: an object with
filter
: the filter object of the form we have been using so farsubqueries
: a record of subqueries that maps the filter i.e. numberOfUsers to a queryquery
: the query builder to build off ofThis function provides sorting functionality. Currently, sorting by, then by is not supported.
This function returns a query with limit
and offset
. Empty options can
also be passed, so it is safe to call formPageLimitOffsetQuery
even
with bogus options.
IFilterQuery<T>
: a generic interface that takes a type argument with a union type of all the supported operations (in, nin, etc).
SortDirection
: a union type of 'ASC' and 'DESC'
ILimitOffsetPage
: an object containing limit and offset as numberse to provide pagination arguments
import { IFilterQuery } from '@dialexa/pleco';
export interface IVehicleFilterInput {
AND: IVehicleFilterInput[];
OR: IVehicleFilterInput[];
make: IFilterQuery<string>;
model: IFilterQuery<string>;
numberOfUsers: IFilterQuery<number>;
highwayMPG: IFilterQuery<number>;
cityMPG: IFilterQuery<number>;
userSurveyRating: IFilterQuery<number>;
}
pleco
is able to support multiple query builders by providing a generic, minimal IQueryBuilder
interface that only requires a subset of a full query builder features. To support another query builder,
all that is needed is to implement the features needed in the required query builder.
Converting from the query builder you are using to an instance of an extension depends on the extension,
but all extensions will convert back to your query builder by calling .build()
.
Current supported query builders:
library | pleco extension |
---|---|
knex | pleco-knex |
id
As always, check the Issues
FAQs
A library for filtering resources on the database layer
The npm package @dialexa/pleco receives a total of 13 weekly downloads. As such, @dialexa/pleco popularity was classified as not popular.
We found that @dialexa/pleco demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 6 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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.