Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@rsql/builder

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rsql/builder

RSQL builder

  • 0.0.1-canary.3.e7aeaa7.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.4K
decreased by-28.25%
Maintainers
1
Weekly downloads
 
Created
Source

@rsql/builder

High level API for RSQL for Node.js and Browsers

⚠️ WARNING: This package is still in development - API may break compatibility without upgrading major version! ⚠️

npm lerna code style: prettier commitizen friendly tested with jest auto release

Installation

# with npm
npm install --save @rsql/builder

# with yarn
yarn add @rsql/builder

API

builder.comparision(selector, operator, value): ComparisionNode

Creates new ComparisionNode - can be used as a base for custom operator factory

builder.<operator>(selector, value): ComparisionNode
builder.eq(selector, value): ComparisionNode
builder.neq(selector, value): ComparisionNode
builder.le(selector, value): ComparisionNode
builder.lt(selector, value): ComparisionNode
builder.ge(selector, value): ComparisionNode
builder.gt(selector, value): ComparisionNode

Creates new ComparisionNode with the predefined operator for single value.

builder.<operator>(selector, values): ComparisionNode
builder.in(selector, values): ComparisionNode
builder.out(selector, values): ComparisionNode

Creates new ComparisionNode with the predefined operator for multiple values.

builder.<operator>(...expressions): LogicNode
builder.and(...expressions): LogicNode
builder.or(...expressions): LogicNode

Creates new LogicNode with the predefined operator for one or more expressions.

builder.emit(ast): string

Emits RSQL string from the Abstract Syntax Tree. Same as emit function from @rsql/emitter package.

builder.parse(rsql): ExpressionNode

Parses RSQL string and returns Abstract Syntax Tree. Same as parse function from @rsql/parser package.

Example

import builder from "@rsql/builder";

function createDateRangeQuery(selector, from, to) {
  return builder.emit(builder.and(builder.ge(selector, from.toISOString()), builder.le(selector, to.toISOString())));
}

console.log(createDateRangeQuery("createdAt", new Date("2019-07-10"), new Date("2020-04-29")));
// createdAt>=2019-07-10T00:00:00.000Z;createAt<=2020-04-29T00:00:00.000Z

License

MIT

FAQs

Package last updated on 05 May 2020

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc