Advance on client side
[vchess.git] / server / models / Variant.js
1 var db = require("../utils/database");
2
3 /*
4 * Structure:
5 * id: integer
6 * name: varchar
7 * description: varchar
8 */
9
10 const VariantModel =
11 {
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
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 },
45
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
57 }
58
59 module.exports = VariantModel;