sql-query-helper
v1.0.2
Published
Help build sql queries in an elegant way.
Downloads
6
Readme
sql-query-helper
Helper to write SQL queries efficiently. Supports Typescript.
Installation
npm i -S sql-query-helper
Usage
import sqlHelper from "sql-query-helper"
Select
sqlHelper().select({
table: "MY_TABLE",
fields: ["ID", "FIRST_NAME", "LAST_NAME"],
where: {
ID: 1
}
});
Insert
sqlHelper().insert({
table: "MY_TABLE",
fields: {
STRING_VAL: "MY_VALUE",
NUMBER_VAL: 1,
DATE_VAL: new Date(2019, 5, 18, 19, 50)
}
});
Update
sqlHelper().update({
table: "MY_TABLE",
fields: {
STRING_UPDATED: "MY_STRING",
NUMBER_UPDATED: 1
},
where: {
ID: 1
}
});
Delete
sqlHelper().delete({
table: "MY_TABLE",
where: {
ID: 1
}
});