0.0.8 • Published 7 years ago

sql-updateobject v0.0.8

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

sql-updateobject

NPM

Returns SQL Query of Update using an Object.

var update = require('sql-updateobject');
// update(<table>, <set object>, <where object>, <operator>, <separator>);

update('food', {'taste': 'sweet'}, {'type': 'chocolate', 'brand': 'cadbury'}, '=', 'OR');
// {
//   "query": "UPDATE \"food\" SET \"taste\" = $1 WHERE \"type\" = $2 OR \"brand\" = $3;",
//   "data": ["sweet", "chocolate", "cadbury"]
// }

update('food', {'cooking': 'baking'}, {'type': '%cake', 'brand': '%bakery'}, 'LIKE');
// {
//   "query": "UPDATE \"food\" SET \"cooking\" = $1 WHERE \"type\" LIKE $2 AND \"brand\" LIKE $3;",
//   "data": ["baking", "%cake", "%bakery"]
// }

update('food', {'quality': 'ephemeral'}, {'price': 2}, '<');
// {
//   "query": "UPDATE \"food\" SET \"quality\" = $1 WHERE \"price\" < $2;",
//   "data": ["ephemeral", 2]
// }

update('food', {'flavour': 'mango'}, {'name': 'Patanjali Aam Biscuits'});
// {
//   "query": "UPDATE \"food\" SET \"flavour\" = $1 WHERE \"name\" = $2;",
//   "data": ["mango", "Patanjali Aam Biscuits"]
// }
0.0.8

7 years ago

0.0.7

8 years ago

0.0.3

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago

0.0.0

8 years ago