Socket
Socket
Sign inDemoInstall

objection-find-query-builder

Package Overview
Dependencies
0
Maintainers
3
Versions
14
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    objection-find-query-builder

query paramter constructor for objection-find


Version published
Weekly downloads
378
increased by7.39%
Maintainers
3
Install size
29.5 kB
Created
Weekly downloads
 

Readme

Source

objection-find-query

Based on original work by AFM Sayem - https://github.com/afm-sayem/objection-find-query

Construct complex api query on the frontend, for endpoints implementing objection-find.

Usage:

Builder


const queryBuilder = require('objection-find-query-builder');

const builder = queryBuilder.builder();
const formattedParams = builder.greaterThan('field', 1).lessThan('field', 3).build();

Eager param mutation


const eagerUtils = require('objection-find-query-builder').eagerUtils;

const modifiedParamsRemoved = eagerUtils.removeFromEagerParam('[param1,param2,param3]', 'param2');
const modifiedParamsAppended = eagerUtils.appendToEagerParam('[param1]', 'param2');

Manual formatting


/*
  expected format:
  {
    op: {
      column: value
    }
  }

  sample input:
  {
    gt: {
      released: 1953,
      gross_income: 200000,
      actors: {
        age: 23
      }
    },
    lt: {
      released: 1984
    },
    in: {
      ratings: [3, 4]
    }
  }

  output:
  {
    'released:gt': 1953,
    'gross_income:gt': 200000,
    'actors.age:gt': 23,
    'released:lt': 1984,
    'ratings:in': 3,4
  }
*/

const queryBuilder = require('objection-find-query-builder');
const formattedParams = queryBuilder.format(params);

Supported operations:

  • greaterThan
  • lessThan
  • greaterThanOrEqual
  • lessThanOrEqual
  • equal
  • inSet (value equals to any value in a given array)
  • anyLike (value of any specified fields matches given string with optional wildcards)
  • anyLikeLower (value of any specified fields matches given string with optional wildcards - case insensitive)
  • eager (retrieve entities from specified relationship eagerly)
  • orderByAsc
  • orderByDesc
  • groupBy
  • count
  • rangeStart
  • rangeEnd

Installation

npm install objection-find-query-builder

Keywords

FAQs

Last updated on 26 Mar 2018

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc