Helper to write SQL queries efficiently. Supports Typescript.
npm i -S sql-query-helper
import sqlHelper from "sql-query-helper"
sqlHelper().select({
table: "MY_TABLE",
fields: ["ID", "FIRST_NAME", "LAST_NAME"],
where: {
ID: 1
}
});
sqlHelper().insert({
table: "MY_TABLE",
fields: {
STRING_VAL: "MY_VALUE",
NUMBER_VAL: 1,
DATE_VAL: new Date(2019, 5, 18, 19, 50)
}
});
sqlHelper().update({
table: "MY_TABLE",
fields: {
STRING_UPDATED: "MY_STRING",
NUMBER_UPDATED: 1
},
where: {
ID: 1
}
});
sqlHelper().delete({
table: "MY_TABLE",
where: {
ID: 1
}
});