+ db.serialize(function() {
+ const query =
+ "SELECT id " +
+ "FROM Players " +
+ "WHERE gid = " + id;
+ db.all(query, (err,players) => {
+ return cb(err, players);
+ });
+ });
+ },
+
+ checkGameUpdate: function(obj)
+ {
+ // Check all that is possible (required) in obj:
+ if (!!obj.move)
+ {
+ if (!obj.move.played.toString().match(/^[0-9]+$/))
+ return "Wrong move played time";
+ if (!obj.move.idx.toString().match(/^[0-9]+$/))
+ return "Wrong move index";
+ }
+ if (!!obj.fen && !obj.fen.match(/^[a-zA-Z0-9, /-]*$/))
+ return "Wrong FEN string";
+ if (!!obj.score && !obj.score.match(/^[012?*\/-]+$/))
+ return "Wrong characters in score";
+ if (!!obj.scoreMsg && !obj.scoreMsg.match(/^[a-zA-Z ]+$/))
+ return "Wrong characters in score message";
+ if (!!obj.chat)
+ return UserModel.checkNameEmail({name: obj.chat.name});
+ return "";
+ },
+
+ // obj can have fields move, chat, fen, drawOffer and/or score
+ update: function(id, obj)
+ {
+ db.parallelize(function() {