1.1.0 • Published 5 years ago
typeorm-front-query-builder v1.1.0
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,photosAvailable 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(): objectGet the query string to form a query on url (?)
public toString(): string