+ // Some fields are not required when showing a games list:
+ const getOneLight = (id, cb2) => {
+ let query =
+ "SELECT g.id, g.vid, g.fen, g.cadence, g.created, g.score, " +
+ "g.scoreMsg, g.deletedByWhite, g.deletedByBlack, v.name AS vname " +
+ "FROM Games g " +
+ "JOIN Variants v " +
+ " ON g.vid = v.id " +
+ "WHERE g.id = " + id;
+ db.get(query, (err, gameInfo) => {
+ query =
+ "SELECT p.uid, p.color, u.name " +
+ "FROM Players p " +
+ "JOIN Users u " +
+ " ON p.uid = u.id " +
+ "WHERE p.gid = " + id;
+ db.all(query, (err2, players) => {
+ query =
+ "SELECT COUNT(*) AS nbMoves " +
+ "FROM Moves " +
+ "WHERE gid = " + id;
+ db.get(query, (err,ret) => {
+ const game = Object.assign({},
+ gameInfo,
+ {
+ players: players,
+ movesCount: ret.nbMoves
+ }
+ );
+ cb2(game);
+ });
+ });
+ });
+ };