JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 9
  • Score
    100M100P100Q45553F
  • License MIT

Programmatically build queries which can be returned as JSON Object and used to fetch data from many sources.

Package Exports

  • blow-query

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (blow-query) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

blow-query

Codeship Status for mchmielarski/blow-query

Query object allows to to programmatically build queries which can be returned as JSON Object and used to fetch data from database, api endpoint etc.

import {Query} from 'blow-query';

const query = new Query();

query
  .greaterThanOrEqual('age', 21)
  .equal('countryCode', 'POL')
  .ascending('age')
  .limit(10);
  
console.log(query.toJSON()); // {where: {age: {$gte: 21}, countryCode: 'POL'}, sort: {age: 1}, limit: 10}  

Query class

class Query {
    equal(field: string, value: any): Query;
    notEqual(field: string, value: any): Query;
    lessThan(field: string, value: any): Query;
    lessThanOrEqual(field: string, value: any): Query;
    greaterThan(field: string, value: any): Query;
    greaterThanOrEqual(field: string, value: any): Query;
    containedIn(field: string, values: any[]): Query;
    notContainedIn(field: string, values: any[]): Query;
    regex(field: string, value: RegExp): Query;
    contains(field: string, value: string): Query;
    startsWith(field: string, value: string): Query;
    endsWith(field: string, value: string): Query;
    ascending(field: string): Query;
    descending(field: string): Query;
    skip(skip: number): Query;
    limit(limit: number): Query;
    select(fields: string[] | string): Query;
    or(query: Query): Query;
    toJSON(): QueryObject;
}

Interfaces

export interface QueryWhere {
    [key: string]: any;
}

export interface QuerySort {
    [key: string]: number;
}

export interface QueryObject {
    where?: QueryWhere;
    limit?: number;
    skip?: number;
    sort?: QuerySort;
    select?: string[];
}