typeorm-front-query-builder
v1.1.0
Published
Easily transform an TypeORM query to url query
Downloads
2
Maintainers
Readme
TypeORM Frontend Query Builder
This library allows you to build url string query for typeorm-server-query-builder.
Installation
npm install typeorm-front-query-builder
Usage
import { Query } from 'typeorm-front-query-builder';
const query = new Query();
query.fieldBetween('age', 18, 45).join(['posts', 'photos']);
const urlQuery = query.toString();
// age__between=18,45&relations=posts,photos
Available Lookups
| Lookup | Method |
| --- | --- |
(none) | fieldEqual(field: string, value: Primitive, not = false): Query
contains | fieldContains(field: string, value: Primitive, not = false): Query
startswith | fieldStartsWith(field: string, value: Primitive, not = false): Query
endswith | fieldEndsWith(field: string, value: Primitive, not = false): Query
isnull | fieldIsNull(field: string, not = false): Query
lt | fieldLessThan(field: string, value: Primitive, not = false): Query
lte | fieldLessThanOrEqual(field: string, value: Primitive, not = false): Query
gt | fieldGreaterThan(field: string, value: Primitive, not = false): Query
gte | fieldGreaterThanOrEqual(field: string, value: Primitive, not = false): Query
in | fieldIn(field: string, elements: Array<Primitive>, not = false): Query
between | fieldBetween(field: string, firstValue: string | number, lastValue: string | number, not = false): Query
Options
| Option | Default |
| --- | --- |
pagination | [enable|disable]Pagnination(): Query
page | setPage(page: number): Query
limit | setLimit(limit: number): Query
order | orderBy(field: string, by: 'ASC' | 'DESC'): Query
join | join(relations: string[]): Query
select | select(fields: string[]): Query
Others methods
Get a raw request object to pass it to an http POST request body for example
public getRawObject(): object
Get the query string to form a query on url (?)
public toString(): string