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

jelly-db-query-parser

v0.1.0

Published

Query parser for SQL scripts

Downloads

8

Readme

db-query-parser

Helper to parse and manage string sql queries

Instalation

install with npm

npm install jelly-db-query-parser

install with yarn

yarn add jelly-db-query-parser

Documentation

Parse script using position 0 of cursor

import { ParserController } from '../index';
const query: string = 'select * from mytable; insert into mytable ("col1") VALUES("blablabla") select * from mytable2;table2;';
const q: string = ParserController.getInstance().getQuery(query, 0, 0);
console.log(q); // select * from mytable

Parse script using position of cursor from 0 until 22 (selected text with mouse)

const q: string = ParserController.getInstance().getQuery(query, 0, 22);
console.log(q); // select * from mytable;

Parse script using position 23 of cursor

const q: string = ParserController.getInstance().getQuery(query, 23, 23);
console.log(q); // insert into mytable ("col1") VALUES("blablabla") select * from mytable2

Search table

const tables: string[] = [];
tables.push('table_1');
tables.push('table_2');
tables.push('table_3');
HelperController.getInstance().setTables(tables);
HelperController.getInstance().setColumns([]);
const result: string[] = HelperController.getInstance().searchTables('able');
console.log(result); // ['table_1', 'table_2', 'table_3']
result = HelperController.getInstance().searchTables('_2');
console.log(result); // ['table_2']

Search snippet

const result: string[] = HelperController.getInstance().searchSnippet('select');
console.log(result); // ['select * from $1']
result = HelperController.getInstance().searchSnippet('select', ['tablexpto']);
console.log(result); // ['select * from tablexpto']

Identify tags and get colors

const result: any = IdentifierController.getInstance().search('select');
console.log(result); // {tag: 'select', color: 'blue'}
const color: string = IdentifierController.getInstance().colorize('select');
console.log(color); // 'blue'

Roadmap

  • Add query parser to identify selected query block (Done)
  • Add tables, columns quick search (Done)
  • Add snippets with quick search (Done)
  • Snippets with properties replace (Done)
  • Identify tags, and assign properties, like color (Done)
  • SQL validator (Backlog)

About

Created with ♥️ by @pedroladeira in Portugal, thanks to other contributors