{"_id":"pg-format","_rev":"29-d6aa076ac76fe5d3183e25a7793a4031","name":"pg-format","description":"Node.js implementation of PostgreSQL's format() to safely create dynamic SQL queries.","dist-tags":{"latest":"1.0.4"},"versions":{"0.1.0":{"author":{"name":"Datalanche, Inc.","url":"https://www.datalanche.com"},"name":"pg-format","homepage":"https://github.com/datalanche/node-pg-format","description":"Node.js implementation of PostgreSQL's format() to safely create dynamic SQL queries.","version":"0.1.0","repository":{"type":"git","url":"https://github.com/datalanche/node-pg-format.git"},"main":"lib/index.js","directories":{"lib":"./lib"},"licenses":[{"type":"MIT","url":"https://github.com/datalanche/node-pg-format/raw/master/LICENSE"}],"engines":{"node":">=0.10"},"dependencies":{},"devDependencies":{"mocha":"*","should":"*"},"bugs":{"url":"https://github.com/datalanche/node-pg-format/issues"},"_id":"pg-format@0.1.0","dist":{"shasum":"e38e668d57d9a7822539cbd351ffaa81692c5f1f","tarball":"https://registry.npmjs.org/pg-format/-/pg-format-0.1.0.tgz","integrity":"sha512-hNNvfPQGBJ9qGPE/fSvgYwPX69ILzfFHL9XtFVX4RrPLgm3aL5jca0Cdsa4deJo3O/ELlCCNlUU8qITG1xGuow==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAZIJFE+JZDx+m6g1ROHL8vqsrVTgFxzuKl8SQgR8bUmAiEAwqlKfrjAL770+E7kRsbqLegw6RcJexMUkeKTkyvXuI4="}]},"_from":".","_npmVersion":"1.3.8","_npmUser":{"name":"datalanche","email":"contact@datalanche.com"},"maintainers":[{"name":"datalanche","email":"contact@datalanche.com"}]},"0.1.1":{"author":{"name":"Datalanche, Inc.","url":"https://www.datalanche.com"},"name":"pg-format","homepage":"https://github.com/datalanche/node-pg-format","description":"Node.js implementation of PostgreSQL's format() to safely create dynamic SQL queries.","version":"0.1.1","repository":{"type":"git","url":"https://github.com/datalanche/node-pg-format.git"},"main":"lib/index.js","directories":{"lib":"./lib"},"licenses":[{"type":"MIT","url":"https://github.com/datalanche/node-pg-format/raw/master/LICENSE"}],"engines":{"node":">=0.10"},"dependencies":{},"devDependencies":{"mocha":"*","should":"*"},"bugs":{"url":"https://github.com/datalanche/node-pg-format/issues"},"_id":"pg-format@0.1.1","dist":{"shasum":"758cfb3aef7e1a3ad4d9858dd8ae8682d7044a12","tarball":"https://registry.npmjs.org/pg-format/-/pg-format-0.1.1.tgz","integrity":"sha512-KIxlZMADougEAyJM0xtkaHnXmKtION24zyKp1MDXaqa6Q0Oi6AYmQC7Mzn8hS4QIFD6sa2UTK6tF8knf1WLdrQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIE2M3H3hwmud08CxMxtcfN/Gb57r3tng0oUCgIADH7KmAiBg1WnuaQdmY++V/AQdpcPjfduGWonIdhMV3cAE4a+Naw=="}]},"_from":".","_npmVersion":"1.3.8","_npmUser":{"name":"datalanche","email":"contact@datalanche.com"},"maintainers":[{"name":"datalanche","email":"contact@datalanche.com"}]},"0.1.2":{"author":{"name":"Datalanche, Inc.","url":"https://www.datalanche.com"},"name":"pg-format","homepage":"https://github.com/datalanche/node-pg-format","description":"Node.js implementation of PostgreSQL's format() to safely create dynamic SQL queries.","version":"0.1.2","repository":{"type":"git","url":"https://github.com/datalanche/node-pg-format.git"},"main":"lib/index.js","directories":{"lib":"./lib"},"licenses":[{"type":"MIT","url":"https://github.com/datalanche/node-pg-format/raw/master/LICENSE"}],"engines":{"node":">=0.10"},"dependencies":{},"devDependencies":{"mocha":"*","should":"*"},"bugs":{"url":"https://github.com/datalanche/node-pg-format/issues"},"_id":"pg-format@0.1.2","dist":{"shasum":"9be5446ab7b5742e712913042e07157752f69a0e","tarball":"https://registry.npmjs.org/pg-format/-/pg-format-0.1.2.tgz","integrity":"sha512-SEPTQbJTOPrv6M3P+U/1aK3rAdVLPva+IpbNQbDW/+FypOI3xfoEI5RjG73cVD/HVXnyJw7mSQ8iSJOJutWi7A==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCYJbVeUxDq1MS+KFr1NWv4w4SSL0mMgJBRRm2sjGtq7wIhALmLbYh/bS8pzUswcR6HBh6E3JMZ9JSahmPsrzH4BZrF"}]},"_from":".","_npmVersion":"1.3.8","_npmUser":{"name":"datalanche","email":"contact@datalanche.com"},"maintainers":[{"name":"datalanche","email":"contact@datalanche.com"}]},"0.1.3":{"author":{"name":"Datalanche, Inc.","url":"https://www.datalanche.com"},"name":"pg-format","homepage":"https://github.com/datalanche/node-pg-format","description":"Node.js implementation of PostgreSQL's format() to safely create dynamic SQL queries.","version":"0.1.3","repository":{"type":"git","url":"https://github.com/datalanche/node-pg-format.git"},"main":"lib/index.js","directories":{"lib":"./lib"},"licenses":[{"type":"MIT","url":"https://github.com/datalanche/node-pg-format/raw/master/LICENSE"}],"engines":{"node":">=0.10"},"dependencies":{},"devDependencies":{"mocha":"*","should":"*"},"bugs":{"url":"https://github.com/datalanche/node-pg-format/issues"},"_id":"pg-format@0.1.3","dist":{"shasum":"5d43dfe0a5fdfef0456f7b5064d0ea4e52882064","tarball":"https://registry.npmjs.org/pg-format/-/pg-format-0.1.3.tgz","integrity":"sha512-yVnDZxiohXVKilYKIbMK52hjrh1/2I0B2N2Ie+Ha+i7pkBMKV1r+YG10CDYk8f6Q4+JfP3IZqdsVUFeTfQSM/w==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIB9FsgS8I2rorchrzbe3zN7wulJx9lqYOCXBkZbwg6NuAiEAkFcvqN3+NJHFTcYest6YN/7cwuBHfO/nhMMcn7gc1ug="}]},"_from":".","_npmVersion":"1.3.8","_npmUser":{"name":"datalanche","email":"contact@datalanche.com"},"maintainers":[{"name":"datalanche","email":"contact@datalanche.com"}]},"0.1.4":{"author":{"name":"Datalanche, Inc.","url":"https://www.datalanche.com"},"name":"pg-format","homepage":"https://github.com/datalanche/node-pg-format","description":"Node.js implementation of PostgreSQL's format() to safely create dynamic SQL queries.","version":"0.1.4","repository":{"type":"git","url":"https://github.com/datalanche/node-pg-format.git"},"main":"lib/index.js","directories":{"lib":"./lib"},"licenses":[{"type":"MIT","url":"https://github.com/datalanche/node-pg-format/raw/master/LICENSE"}],"engines":{"node":">=0.10"},"dependencies":{},"devDependencies":{"mocha":"*","should":"*"},"bugs":{"url":"https://github.com/datalanche/node-pg-format/issues"},"_id":"pg-format@0.1.4","dist":{"shasum":"13983328c852a18b3db6a841f66ea5bc649f1894","tarball":"https://registry.npmjs.org/pg-format/-/pg-format-0.1.4.tgz","integrity":"sha512-WHYlZgYLt7f5TRJewxpy9E8TrqzLgx8GvqENRTewQ+UNvD8zs5WleKVecwH6wNxLqO7w4UOTibupC6e5QSVSeQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCDkHA7kk/+ybQ1l3HmTrqHmb27ALfVCq/Y5icypF4LSAIhAMkbwwTchkvw7CDwXD41lT12tikny544p57Qbdco4S5D"}]},"_from":".","_npmVersion":"1.3.8","_npmUser":{"name":"datalanche","email":"contact@datalanche.com"},"maintainers":[{"name":"datalanche","email":"contact@datalanche.com"}]},"1.0.1":{"author":{"name":"Datalanche, Inc.","url":"https://www.datalanche.com"},"name":"pg-format","license":"MIT","homepage":"https://github.com/datalanche/node-pg-format","description":"Node.js implementation of PostgreSQL's format() to safely create dynamic SQL queries.","version":"1.0.1","repository":{"type":"git","url":"git+https://github.com/datalanche/node-pg-format.git"},"main":"lib/index.js","directories":{"lib":"./lib"},"engines":{"node":">=4.0"},"dependencies":{},"devDependencies":{"mocha":"2.3.3","should":"7.1.1"},"scripts":{"test":"node ./node_modules/mocha/bin/mocha"},"gitHead":"506e660b205c49b4050a1974f3e47d22d73b1755","bugs":{"url":"https://github.com/datalanche/node-pg-format/issues"},"_id":"pg-format@1.0.1","_shasum":"39d08f604a721a88d209f6af640d3f8435c2ed93","_from":".","_npmVersion":"2.14.4","_nodeVersion":"4.1.2","_npmUser":{"name":"datalanche","email":"contact@datalanche.com"},"dist":{"shasum":"39d08f604a721a88d209f6af640d3f8435c2ed93","tarball":"https://registry.npmjs.org/pg-format/-/pg-format-1.0.1.tgz","integrity":"sha512-Pi0b9TtaN9M+I4Jt1H25754XglrEvGmq7ifMWZQGCuDMowbtulXr0v+gU6HWIGVeXt6mJEKiSqLFUq0bXFsMhg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQC7sjTaXrFTsk8iJJPg7Btvo5/zMOv68VQh7NHArPMocAIhAL6W9gSkWFEjke4DokV4HRKSqUbHd/yms3gvABSB5IGL"}]},"maintainers":[{"name":"datalanche","email":"contact@datalanche.com"}]},"1.0.2":{"author":{"name":"Datalanche, Inc.","url":"https://www.datalanche.com"},"name":"pg-format","license":"MIT","homepage":"https://github.com/datalanche/node-pg-format","description":"Node.js implementation of PostgreSQL's format() to safely create dynamic SQL queries.","version":"1.0.2","repository":{"type":"git","url":"git+https://github.com/datalanche/node-pg-format.git"},"main":"lib/index.js","directories":{"lib":"./lib"},"engines":{"node":">=4.0"},"dependencies":{},"devDependencies":{"istanbul":"^0.4.2","mocha":"2.4.5","should":"8.2.1"},"scripts":{"test":"node ./node_modules/mocha/bin/mocha","cover-test":"istanbul cover node_modules/.bin/_mocha"},"gitHead":"ef61fb57db0cde7292c0be090eb49616a439f12b","bugs":{"url":"https://github.com/datalanche/node-pg-format/issues"},"_id":"pg-format@1.0.2","_shasum":"4e35781af93e4929cad2a9c32b2ac7f5418c7345","_from":".","_npmVersion":"2.14.12","_nodeVersion":"4.2.6","_npmUser":{"name":"datalanche","email":"contact@datalanche.com"},"dist":{"shasum":"4e35781af93e4929cad2a9c32b2ac7f5418c7345","tarball":"https://registry.npmjs.org/pg-format/-/pg-format-1.0.2.tgz","integrity":"sha512-b0xW4BqeSQPsOgCWcnEbuVFyDv72a9uEyLklqikHc7qk3rJfmmPqO8L619in8O1Njv/kQ9JnCUi6UDKnVh+daQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCJ9VnfKd35vNJOzokVqIiDgo2uzlkshvBfEIjq3igoLQIhALNt9V2rngJPqiO/dMNauONDLoAx3BMYiJe71QEKQbrO"}]},"maintainers":[{"name":"datalanche","email":"contact@datalanche.com"}],"_npmOperationalInternal":{"host":"packages-9-west.internal.npmjs.com","tmp":"tmp/pg-format-1.0.2.tgz_1455564785505_0.8407828728668392"}},"1.0.3":{"author":{"name":"Datalanche, Inc.","url":"https://www.datalanche.com"},"name":"pg-format","license":"MIT","homepage":"https://github.com/datalanche/node-pg-format","description":"Node.js implementation of PostgreSQL's format() to safely create dynamic SQL queries.","version":"1.0.3","repository":{"type":"git","url":"git+https://github.com/datalanche/node-pg-format.git"},"main":"lib/index.js","directories":{"lib":"./lib"},"engines":{"node":">=4.0"},"dependencies":{},"devDependencies":{"istanbul":"0.4.2","mocha":"2.4.5","should":"8.2.1"},"scripts":{"test":"node ./node_modules/mocha/bin/mocha","cover-test":"istanbul cover node_modules/.bin/_mocha"},"gitHead":"153a8b2a7858e67601b32d5c609a07c008a1c896","bugs":{"url":"https://github.com/datalanche/node-pg-format/issues"},"_id":"pg-format@1.0.3","_shasum":"15b5e5cf29e2417f97c018e11ac26e4f62bae05b","_from":".","_npmVersion":"2.15.8","_nodeVersion":"4.4.7","_npmUser":{"name":"datalanche","email":"contact@datalanche.com"},"dist":{"shasum":"15b5e5cf29e2417f97c018e11ac26e4f62bae05b","tarball":"https://registry.npmjs.org/pg-format/-/pg-format-1.0.3.tgz","integrity":"sha512-eKCiPTFHXPqtv4fx9fxh3OXRHMX9YkVjBV7s0ErBzbhZHawUmWJvl0ldnPIitc7F478Q/tWAuB06Sph5QhDwxA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCScGfhbSwV2h1NoNW+pbktBJp1XyAXn73f9OhCHtww+AIgb1WNv1Ngi385SYowa6sR2oFeR15il8gwUqNHe4CcpiY="}]},"maintainers":[{"name":"datalanche","email":"contact@datalanche.com"}],"_npmOperationalInternal":{"host":"packages-16-east.internal.npmjs.com","tmp":"tmp/pg-format-1.0.3.tgz_1473955607825_0.0363882496021688"}},"1.0.4":{"author":{"name":"Datalanche, Inc.","url":"https://www.datalanche.com"},"name":"pg-format","license":"MIT","homepage":"https://github.com/datalanche/node-pg-format","description":"Node.js implementation of PostgreSQL's format() to safely create dynamic SQL queries.","version":"1.0.4","repository":{"type":"git","url":"git+https://github.com/datalanche/node-pg-format.git"},"main":"lib/index.js","directories":{"lib":"./lib"},"engines":{"node":">=4.0"},"dependencies":{},"devDependencies":{"istanbul":"0.4.2","mocha":"2.4.5","should":"8.2.1"},"scripts":{"test":"node ./node_modules/mocha/bin/mocha","cover-test":"istanbul cover node_modules/.bin/_mocha"},"gitHead":"1deed4e07d24bc3f06db3652f3bb10a116a8d1a5","bugs":{"url":"https://github.com/datalanche/node-pg-format/issues"},"_id":"pg-format@1.0.4","_shasum":"27734236c2ad3f4e5064915a59334e20040a828e","_from":".","_npmVersion":"2.15.11","_nodeVersion":"4.6.2","_npmUser":{"name":"datalanche","email":"contact@datalanche.com"},"dist":{"shasum":"27734236c2ad3f4e5064915a59334e20040a828e","tarball":"https://registry.npmjs.org/pg-format/-/pg-format-1.0.4.tgz","integrity":"sha512-YyKEF78pEA6wwTAqOUaHIN/rWpfzzIuMh9KdAhc3rSLQ/7zkRFcCgYBAEGatDstLyZw4g0s9SNICmaTGnBVeyw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCccUTf3GuHxTlEM1ct65TzuiA80Oj1sz1mfh8fvHSl4wIgYUPfPzASGe3gzkXAp/RmStcxcq6jcPDpICmlhaeqm+8="}]},"maintainers":[{"name":"datalanche","email":"contact@datalanche.com"}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/pg-format-1.0.4.tgz_1487462342939_0.5932568607386202"}}},"readme":"node-pg-format\n==============\n\nNode.js implementation of [PostgreSQL format()](http://www.postgresql.org/docs/9.3/static/functions-string.html#FUNCTIONS-STRING-FORMAT) to safely create dynamic SQL queries. SQL identifiers and literals are escaped to help prevent SQL injection. The behavior is equivalent to [PostgreSQL format()](http://www.postgresql.org/docs/9.3/static/functions-string.html#FUNCTIONS-STRING-FORMAT). This module also supports Node buffers, arrays, and objects which is explained [below](#arrobject).\n\n## Install\n\n    npm install pg-format\n\n## Example\n```js\nvar format = require('pg-format');\nvar sql = format('SELECT * FROM %I WHERE my_col = %L %s', 'my_table', 34, 'LIMIT 10');\nconsole.log(sql); // SELECT * FROM my_table WHERE my_col = '34' LIMIT 10\n```\n\n## API\n\n### format(fmt, ...)\nReturns a formatted string based on ```fmt``` which has a style similar to the C function ```sprintf()```.\n* ```%%``` outputs a literal ```%``` character.\n* ```%I``` outputs an escaped SQL identifier.\n* ```%L``` outputs an escaped SQL literal.\n* ```%s``` outputs a simple string.\n\n### format.config(cfg)\nChanges the global configuration. You can change which letters are used to denote identifiers, literals, and strings in the formatted string. This is useful when the formatted string contains a PL/pgSQL function which calls [PostgreSQL format()](http://www.postgresql.org/docs/9.3/static/functions-string.html#FUNCTIONS-STRING-FORMAT) itself.\n```js\nvar format = require('pg-format');\nformat.config({\n    pattern: {\n        ident: 'V',\n        literal: 'C',\n        string: 't'\n    }\n});\nformat.config(); // reset to default\n```\n\n### format.ident(input)\nReturns the input as an escaped SQL identifier string. ```undefined```, ```null```, and objects will throw an error.\n\n### format.literal(input)\nReturns the input as an escaped SQL literal string. ```undefined``` and ```null``` will return ```'NULL'```;\n\n### format.string(input)\nReturns the input as a simple string. ```undefined``` and ```null``` will return an empty string. If an array element is ```undefined``` or ```null```, it will be removed from the output string.\n\n### format.withArray(fmt, array)\nSame as ```format(fmt, ...)``` except parameters are provided in an array rather than as function arguments. This is useful when dynamically creating a SQL query and the number of parameters is unknown or variable.\n\n## <a name=\"buffer\"></a> Node Buffers\nNode buffers can be used for literals (```%L```) and strings (```%s```), and will be converted to [PostgreSQL bytea hex format](http://www.postgresql.org/docs/9.3/static/datatype-binary.html).\n\n## <a name=\"arrobject\"></a> Arrays and Objects\nFor arrays, each element is escaped when appropriate and concatenated to a comma-delimited string. Nested arrays are turned into grouped lists (for bulk inserts), e.g. [['a', 'b'], ['c', 'd']] turns into ('a', 'b'), ('c', 'd'). Nested array expansion can be used for literals (```%L```) and strings (```%s```), but not identifiers (```%I```).  \nFor objects, ```JSON.stringify()``` is called and the resulting string is escaped if appropriate. Objects can be used for literals (```%L```) and strings (```%s```), but not identifiers (```%I```). See the example below.\n\n```js\nvar format = require('pg-format');\n\nvar myArray = [ 1, 2, 3 ];\nvar myObject = { a: 1, b: 2 };\nvar myNestedArray = [['a', 1], ['b', 2]];\n\nvar sql = format('SELECT * FROM t WHERE c1 IN (%L) AND c2 = %L', myArray, myObject);\nconsole.log(sql); // SELECT * FROM t WHERE c1 IN ('1','2','3') AND c2 = '{\"a\":1,\"b\":2}'\n\nsql = format('INSERT INTO t (name, age) VALUES %L', myNestedArray); \nconsole.log(sql); // INSERT INTO t (name, age) VALUES ('a', '1'), ('b', '2')\n```\n\n## Testing\n\n```\nnpm install\nnpm test\n```","maintainers":[{"name":"datalanche","email":"contact@datalanche.com"}],"time":{"modified":"2022-06-23T19:40:25.327Z","created":"2014-10-21T17:16:11.626Z","0.1.0":"2014-10-21T17:16:12.610Z","0.1.1":"2014-10-29T18:30:14.168Z","0.1.2":"2014-11-02T16:46:44.099Z","0.1.3":"2014-12-11T19:32:21.792Z","0.1.4":"2014-12-11T19:38:31.420Z","1.0.1":"2015-10-28T17:58:46.619Z","1.0.2":"2016-02-15T19:33:09.277Z","1.0.3":"2016-09-15T16:06:50.459Z","1.0.4":"2017-02-18T23:59:04.820Z"},"readmeFilename":"README.md","homepage":"https://github.com/datalanche/node-pg-format","repository":{"type":"git","url":"git+https://github.com/datalanche/node-pg-format.git"},"author":{"name":"Datalanche, Inc.","url":"https://www.datalanche.com"},"bugs":{"url":"https://github.com/datalanche/node-pg-format/issues"},"license":"MIT","users":{"jrnail23":true,"subchen":true,"rapomon":true}}