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

@panosoft/sql-utils

v0.1.9

Published

Utilities to assist with SQL script generation.

Downloads

17

Readme

sql-utils

Utilities to assist with SQL script generation.

npm version npm license Travis David npm downloads

Installation

npm install @panosoft/sql-utils

Usage

var utils = require('sql-utils');

API


buildCriteria ( criteriaArrays )

Joins an array into a criteria string delimited by AND's and OR's.

Arguments

  • criteriaArrays - An array or an array of arrays to be joined.

Examples

var array = ['a', 'b', 'c'];
var criteria = utils.buildCriteria(array);
console.log(criteria); // '(a AND b AND c)'
var arrays = [
  ['a', 'b', 'c'],
  ['d', 'e', 'f']
];
var criteria = utils.buildCriteria(arrays);
console.log(criteria); // '((a AND b AND c) OR (d AND e AND f))'

parenthesize ( string )

Wraps a string with parenthesis.

Arguments

  • string - A string to wrap.

Example

var string = utils.parenthesize('a');
console.log(string); // '(a)'

quote ( string )

Wraps a string with single quotes.

Arguments

  • string - A string to wrap.

Example

var string = utils.quote('a');
console.log(string); // "'a'"

quoteList ( strings )

Converts an array of strings to a quoted comma delimited list.

Arguments

  • strings - An array of strings to convert.

Example

var string = utils.quoteList(['a', 'b', 'c']);
console.log(string); // "'a','b','c'"

parseOrderColumn ( orderColumn )

Returns an Array with the orderColumn in index 0 and optionally ASC/DESC in index 1.

Arguments

  • orderColumn - A string definining a SQL ordering.

Examples

var orderColumn = 'userName ASC';
utils.parseOrderColumn(orderColumn); // ['userName', 'ASC']
var orderColumn = 'refNum';
utils.parseOrderColumn(orderColumn); // ['refNum']

replaceOrderColumns ( orderColumns, componentColumns )

Takes an Array of Order Columns and replace any column that has components in the Object of Component Columns. This will preserve the ASC/DESC suffix in the original Order Column.

This is VERY useful for replacing a name column with its components, i.e. first, last and middle.

Arguments

  • orderColumns - An Array of Order Columns.
  • componentColumns - An Object of component columns where the key is the order column and the value is an Array of component columns.

Examples

var orderColumns = ['userName ASC', 'clientName DESC', 'refNum'];
var componentColumns = {
	userName: ['usrLastName', 'usrFirstName', 'usrMI'],
	clientName: ['clientLastName', 'clientFirstName', 'clientMI']
};
var columns = utils.replaceOrderColumns(orderColumns, componentColumns);
console.log(columns);
/*[
	'usrLastName ASC',
	'usrFirstName ASC',
	'usrMI ASC',
	'clientLastName DESC',
	'clientFirstName DESC',
	'clientMI DESC',
	'refNum'
]*/```