metafilters
v5.3.30
Published
MetaFilters - library for dealing with filters
Downloads
82
Readme
MetaFilters
Usage
import metafilters from "metafilters";
const { nodes, count, cursor } = await metafilters(database.getRepository(PersonEntity), {
filters: {
firstName: { type: "string", value: "Joe" },
age: {
type: "number",
filters: [
{ operator: "GE", value: 21 },
{ operator: "LE", value: 60 },
],
},
},
sort: { age: "DESC" },
limit: 10,
});
Install
- Npm:
npm install metafilters
- Yarn:
yarn add metafilters
API
Filters
String
interface IStringInput {
type: "string";
filters: {
value: Nullable<string>;
operator?: Nullable<"EQ" | "LIKE">; // defaults to LIKE
}[];
}
Number
interface INumberInput {
type: "number";
filters: {
value: Nullable<number>;
operator?: "GT" | "LT" | "GE" | "LE" | "EQ" | "NE"; // defaults to EQ
}[];
}
with little explanation of those operators:
EQ
- Equal toNE
- Not equal toGT
- Greater thanGE
- Greater than or equal toLT
- Less thanLE
- Less than or equal to
Boolean
interface IBooleanInput {
type: "boolean";
value: Nullable<boolean>;
}
...more filters to come!
Cursor
...