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 | { |
98db2082 BA |
12 | // This is duplicated in client. TODO: really required here? |
13 | NbPlayers: | |
14 | { | |
15 | "Alice": [2,3,4], | |
16 | "Antiking": [2,3,4], | |
17 | "Atomic": [2,3,4], | |
18 | "Baroque": [2,3,4], | |
19 | "Berolina": [2,4], | |
20 | "Checkered": [2,3,4], | |
21 | "Chess960": [2,3,4], | |
22 | "Crazyhouse": [2,3,4], | |
23 | "Dark": [2,3,4], | |
24 | "Extinction": [2,3,4], | |
25 | "Grand": [2], | |
26 | "Losers": [2,3,4], | |
27 | "Magnetic": [2], | |
28 | "Marseille": [2], | |
29 | "Switching": [2,3,4], | |
30 | "Upsidedown": [2], | |
31 | "Wildebeest": [2], | |
32 | "Zen": [2,3,4], | |
33 | }, | |
34 | ||
ab4f4bf2 BA |
35 | getByName: function(name, callback) |
36 | { | |
37 | db.serialize(function() { | |
38 | const query = | |
39 | "SELECT * " + | |
40 | "FROM Variants " + | |
41 | "WHERE name='" + name + "'"; | |
42 | db.get(query, callback); | |
43 | }); | |
44 | }, | |
8d7e2786 | 45 | |
ab4f4bf2 BA |
46 | getAll: function(callback) |
47 | { | |
48 | db.serialize(function() { | |
49 | const query = | |
50 | "SELECT * " + | |
51 | "FROM Variants"; | |
52 | db.all(query, callback); | |
53 | }); | |
54 | }, | |
55 | ||
56 | //create, update, delete: directly in DB | |
8d7e2786 BA |
57 | } |
58 | ||
ab4f4bf2 | 59 | module.exports = VariantModel; |