-
Notifications
You must be signed in to change notification settings - Fork 0
/
handler.js
30 lines (22 loc) · 901 Bytes
/
handler.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
const models = require('./models');
exports.createSqlite = async function(tableName, data) {
const result = await tableName.create(data);
return result;
};
exports.getSqlite = async function(tableName, queryParams, atr ) {
const result = await tableName.findOne({ where: queryParams, attributes: atr});
return result;
};
exports.updateSqlite = async function(tableName, newData, queryParams) {
await tableName.update(newData, { where: queryParams });
const result = await tableName.findOne({ where: queryParams });
return result;
};
exports.getSqlites = async function(tableName, atr, lim, queryParams) {
const result = await tableName.findAll({attributes: atr, limit: lim, where: queryParams });
return result;
};
exports.deleteSqlite = async function(tableName, queryParams) {
await tableName.destroy({ where: queryParams });
return true;
};