JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 78
  • Score
    100M100P100Q69266F
  • License ISC

A Small library to create sql queries from JSON objects

Package Exports

  • sql-json-generator

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (sql-json-generator) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

sql-json-generator

Generate SQL command from JSON object

Install

Install with npm install sql-json-generator

´´´ var SQLGenerator = require('sql-json-generator'); var sqlGenerator = new SQLGenerator(); ´´´

API

update

.update( queryData , callback )

The first paramenter contains the data used to produce the SQL query The callback returns two parameters, error and result

sqlParams = {
    update: 'mytable',
    set : {
        field_b: 1
    },
    where: {
        field_a: 1
    }
}

sqlGenerator.update( sqlParams , function ( err, result ) {

});

will return:

err: null
result: UPDATE  `mytable`  SET `field_b` = '1' WHERE `field_a` = '1'

Formating queryData

WHERE

where: condition

AND

Simple AND
{
    field_a: 1,
    field_b: 1,
    field_c: 1
}

field_a = '1' AND field_b = '1' AND field_c = '1'