+ if (obj.drawOffer == "n") //Special "None" update
+ obj.drawOffer = "";
+ modifs += "drawOffer = '" + obj.drawOffer + "',";
+ }
+ if (obj.fen)
+ modifs += "fen = '" + obj.fen + "',";
+ if (obj.score)
+ modifs += "score = '" + obj.score + "',";
+ if (obj.scoreMsg)
+ modifs += "scoreMsg = '" + obj.scoreMsg + "',";
+ modifs = modifs.slice(0,-1); //remove last comma
+ if (modifs.length > 0)
+ {
+ query += modifs + " WHERE id = " + id;
+ db.run(query);
+ }
+ if (obj.move)
+ {
+ const m = obj.move;
+ query =
+ "INSERT INTO Moves (gid, squares, played, idx) VALUES " +
+ "(" + id + ",?," + m.played + "," + m.idx + ")";
+ db.run(query, JSON.stringify(m.squares));
+ }
+ if (obj.chat)
+ {
+ query =
+ "INSERT INTO Chats (gid, msg, name, added) VALUES ("
+ + id + ",?,'" + obj.chat.name + "'," + Date.now() + ")";
+ db.run(query, obj.chat.msg);