npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

waterline-query-language-parser

v0.0.18

Published

Generador de query de busqueda compatible con waterline query language

Downloads

24

Readme

Waterline Query Language Parser

Contenido

Dado que sailsjs provee un blueprint-api. Esta librería aprovecha la ruta find de tal forma genera el querystring where y asi realizar una búsqueda compleja utilizando etiquetas.

El query de busqueda tiene la siguiente forma

etiqueta1: descripcion 1 etiqueta2: descripcion 2

Instalación

npm install waterline-query-language-parser --save

Uso

import Query from "waterline-query-language-parse"
parser = new Query('etiquetas: papel descripcion: papel blando');

parser.etiquetas // ['etiquetas', 'descripcion']
parser.descripcion // ['papel', 'papel blando']

parser.query // where={"or":[{"etiquetas":{"contains":"papel"}},{"descripcion":{"contains":"papel blando"}}]}

Builder pattern

Ahora puedes añadir mas etiquetas y descripción al query original

import Query from "waterline-query-language-parse"

parser = new Query('etiquetas: papel');

parser.etiquetas // ['etiquetas']
parser.descripcion // ['papel']

parse.addQuery('descripcion: papel blando');

parser.etiquetas // ['etiquetas', 'descripcion']
parser.descripcion // ['papel', 'papel blando']

parser.query // where={"or":[{"etiquetas":{"contains":"papel"}},{"descripcion":{"contains":"papel blando"}}]}

Modificadores

Tú puedes crear un query de búsqueda con los siguientes modificadores: mayor, menor, mayor que, menor que

  etiqueta:> descripcion  // mayor que
  etiqueta:>= descripcion  // mayor igual
  etiqueta:< descripcion  // menor que
  etiqueta:<= descripcion  // menor igual

Si quieres que sea igual no debes utilizar ningun modificador.

import Query from "waterline-query-language-parse"

parser = new Query('pagos:> 100');
parse.addQuery('cuota:<= 15');

parser.etiquetas // ['pagos', 'cuota']
parser.descripcion // ['100', '15']

parser.query // where={"or":[{"etiquetas":{">":5}},{"cuota":{"<=":15}}]}

Fechas

Tambíen puedes hacer búsqueda de fechas utilizando modificadores descritos anteriormente o por medio de un rango. De esta forma se realiza una búsqueda a partir de una fecha de inicio y fin de fecha.

Formato simple: YYYY/MM/DD

import Query from "waterline-query-language-parse"

parser = new Query('fechaInicio:> 2018/06/05');

parser.etiquetas // ['fechaInicio']
parser.descripcion // ['2018/06/05']

parser.query // where={"or":[{"fechaInicio":{">":"2018-06-05T05:00:00.000Z"}}]}

Formato rango: YYYY/MM/DD-YYYY/MM/DD

import Query from "waterline-query-language-parse"

parser = new Query('fechaInicio: 2018/06/05-2018/12/15');

parser.etiquetas // ['fechaInicio']
parser.descripcion // ['2018/06/05-2018/12/15']

parser.query // where={"or":[{"fechaInicio":{">":"2018-06-05T05:00:00.000Z","<":"2018-12-15T05:00:00.000Z"}}]}

Referencias

Para saber más información sobre el query language de waterline visita query-language

Contribuciones

Ver Guía de contribuciones


Since sailsjs provides a blueprint-api. This library uses the path find to generate the querystring where and thus perform a complex search using tags.

The search query has the following form

tag1: description 1 tag2: description 2

Installation

npm install waterline-query-language-parser --save

Use

import Query from "waterline-query-language-parse"
parser = new Query('etiquetas: papel descripcion: papel blando');

parser.etiquetas // ['etiquetas', 'descripcion']
parser.descripcion // ['papel', 'papel blando']

parser.query // where={"or":[{"etiquetas":{"contains":"papel"}},{"descripcion":{"contains":"papel blando"}}]}

Builder pattern

Now you can add more tags and description to the original query

import Query from "waterline-query-language-parse"

parser = new Query('etiquetas: papel');

parser.etiquetas // ['etiquetas']
parser.descripcion // ['papel']

parse.addQuery('descripcion: papel blando');

parser.etiquetas // ['etiquetas', 'descripcion']
parser.descripcion // ['papel', 'papel blando']

parser.query // where={"or":[{"etiquetas":{"contains":"papel"}},{"descripcion":{"contains":"papel blando"}}]}

Modifiers

You can create a search query with the following modifiers: major, minor, greater than, less than

  etiqueta:> descripcion  // greater than
  etiqueta:>= descripcion  // greater than or equal to
  etiqueta:< descripcion  // less than
  etiqueta:<= descripcion  // less than or equal to 

If you want it to be the same you should not use any modifier.

import Query from "waterline-query-language-parse"

parser = new Query('pagos:> 100');
parse.addQuery('cuota:<= 15');

parser.etiquetas // ['pagos', 'cuota']
parser.descripcion // ['100', '15']

parser.query // where={"or":[{"etiquetas":{">":5}},{"cuota":{"<=":15}}]}

Dates

You can also search for dates using modifiers described above or by means of a ** range **. In this way, a search is carried out starting from a start date and ending date.

Simple format: YYYY/MM/DD

import Query from "waterline-query-language-parse"

parser = new Query('fechaInicio:> 2018/06/05');

parser.etiquetas // ['fechaInicio']
parser.descripcion // ['2018/06/05']

parser.query // where={"or":[{"fechaInicio":{">":"2018-06-05T05:00:00.000Z"}}]}

Format range: YYYY/MM/DD-YYYY/MN/DD

import Query from "waterline-query-language-parse"

parser = new Query('fechaInicio: 2018/06/05-2018/12/15');

parser.etiquetas // ['fechaInicio']
parser.descripcion // ['2018/06/05-2018/12/15']

parser.query // where={"or":[{"fechaInicio":{">":"2018-06-05T05:00:00.000Z","<":"2018-12-15T05:00:00.000Z"}}]}

References

To know more information about the query language of waterline visit query-language.

Contributions

See Contributions Guide