Socket
Socket
Sign inDemoInstall

monologue

Package Overview
Dependencies
Maintainers
1
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

monologue - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

.npmignore

86

monologue.js

@@ -13,3 +13,3 @@ (function() {

function Query() {
function Monologue() {
this.params = {};

@@ -19,10 +19,8 @@ };

if( typeof module !== "undefined" && module.exports ) {
module.exports = new Query;
module.exports = new Monologue;
}
else {
root.mono = new Query;
root.monologue = new Monologue;
}
/**

@@ -33,3 +31,3 @@ * Creates a select statement using properties defined before calling method

Query.prototype.select = function( c, t ) {
Monologue.prototype.select = function( c, t ) {
c = ( typeof c === "string" ? c : c.join(", ") );

@@ -42,3 +40,3 @@

Query.prototype.where = function( w, separator ) {
Monologue.prototype.where = function( w, separator ) {
separator = ( typeof separator === "undefined" ? "AND" : separator );

@@ -67,3 +65,3 @@

Query.prototype.having = function( h, separator ) {
Monologue.prototype.having = function( h, separator ) {
separator = ( typeof separator === "undefined" ? "AND" : separator );

@@ -92,3 +90,3 @@

Query.prototype.in = function( ins )
Monologue.prototype.in = function( ins )
{

@@ -111,3 +109,3 @@ i = [];

Query.prototype.like = function( like, separator ) {
Monologue.prototype.like = function( like, separator ) {
separator = separator || "AND";

@@ -133,3 +131,3 @@

Query.prototype.between = function( one, two )
Monologue.prototype.between = function( one, two )
{

@@ -157,3 +155,3 @@ // a unique id of some kind is required to dsitinguish fields, so a md5

// group, direction
Query.prototype.group = function( g, d ) {
Monologue.prototype.group = function( g, d ) {
d = d || 'ASC';

@@ -170,3 +168,3 @@

// order, direction
Query.prototype.order = function( o, d ) {
Monologue.prototype.order = function( o, d ) {
d = d || 'ASC';

@@ -183,3 +181,3 @@

// limit, offset
Query.prototype.limit = function( l, o )
Monologue.prototype.limit = function( l, o )
{

@@ -195,3 +193,3 @@ yoe.limit = ( typeof o === "undefined" ? l : o + ", " + l );

Query.prototype.query = function()
Monologue.prototype.query = function()
{

@@ -222,3 +220,3 @@ if( yoe.where.length > 0 )

// Query.prototype.insert = function( $table, array $params )
// Monologue.prototype.insert = function( $table, array $params )
// {

@@ -280,20 +278,25 @@ // $columns = array();

Query.prototype.update = function( table, params ) {
Monologue.prototype.insert = function( table, params ) {
if( typeof params !== "string" ) {
this.params = params;
var columns = [];
// if( toString.call(params) === "[object Array]" ) { }
var columns = [], values = [];
params.map( function( v, k ) {
k = k.replace( rx, '' );
columns.push( k + " = :" + k )
});
for( k in params ) {
var p = k.replace( rx, '' );
this.params[p] = params[k];
columns.push( k );
values.push( ":" + p );
}
columns = columns.join( ', ' );
values = values.join( ', ' );
columns = " (" + columns + ") VALUES " + "(" + values + ")";
}
else {
columns = params;
var columns = " " + params;
}
this.query = "UPDATE " + table + " SET " + columns;
this.query = "INSERT INTO " + table + columns;

@@ -305,2 +308,33 @@ return this;

/**
* Generates an update statement
* @param string $table
* @param array $params
* @param array $where
* @return string
*/
Monologue.prototype.update = function( table, params ) {
if( typeof params !== "string" ) {
var columns = [];
for( k in params ) {
var p = k.replace( rx, '' );
columns.push( k + " = :" + p );
this.params[p] = params[k];
}
columns = " SET " + columns.join( ', ' );
}
else {
columns = " " + params;
}
this.query = "UPDATE " + table + columns;
return this;
};
/**
* Creates a select statement using properties defined before calling method

@@ -310,3 +344,3 @@ * @return string the generated query string

Query.prototype.delete = function( t )
Monologue.prototype.delete = function( t )
{

@@ -313,0 +347,0 @@ yoe.table = t;

{
"name": "monologue",
"version": "0.0.3",
"version": "0.0.4",
"description": "Steamlined MySQL query building",

@@ -5,0 +5,0 @@ "main": "./monologue.js",

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