Commit | Line | Data |
---|---|---|
8d7e2786 BA |
1 | var db = require("../utils/database"); |
2 | ||
3 | /* | |
4 | * Structure: | |
c018b304 | 5 | * id: integer |
8d7e2786 BA |
6 | * name: varchar |
7 | * description: varchar | |
8 | */ | |
9 | ||
ab4f4bf2 | 10 | const VariantModel = |
8d7e2786 | 11 | { |
ab4f4bf2 BA |
12 | getByName: function(name, callback) |
13 | { | |
14 | db.serialize(function() { | |
15 | const query = | |
16 | "SELECT * " + | |
17 | "FROM Variants " + | |
18 | "WHERE name='" + name + "'"; | |
19 | db.get(query, callback); | |
20 | }); | |
21 | }, | |
8d7e2786 | 22 | |
ab4f4bf2 BA |
23 | getAll: function(callback) |
24 | { | |
25 | db.serialize(function() { | |
26 | const query = | |
27 | "SELECT * " + | |
28 | "FROM Variants"; | |
29 | db.all(query, callback); | |
30 | }); | |
31 | }, | |
32 | ||
33 | //create, update, delete: directly in DB | |
8d7e2786 BA |
34 | } |
35 | ||
ab4f4bf2 | 36 | module.exports = VariantModel; |