forked from kylecoberly/twitter-test
-
Notifications
You must be signed in to change notification settings - Fork 1
/
queries.js
36 lines (35 loc) · 806 Bytes
/
queries.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
29
30
31
32
33
34
35
36
const database = require("./database-connection");
module.exports = {
list(table) {
return database(table).select();
},
read(id, table) {
return database(table)
.where("id", id)
.first();
},
getTrends(id, table) {
return database(table)
.where("WOE_ID", id)
.returning("*")
.first();
},
createLocations(personalLocations) {
return database("personalLocations")
.insert(personalLocations)
.returning("*")
.then(record => record[0]);
},
updateLocations(id, request) {
return database("personalLocations")
.update(request)
.where("id", id)
.returning("*")
.then(record => record);
},
deleteLocations(id) {
return database("personalLocations")
.delete()
.where("id", id);
}
};