X-Git-Url: https://git.auder.net/?p=vchess.git;a=blobdiff_plain;f=server%2Fmodels%2FProblem.js;h=5c9af0b1803d6ff675d4970804bbfd5f74a4d48a;hp=136fb649d6651caf169256c7df97a7ed9f39126c;hb=0234201fb338fc239d6f613c677fa932c7c3697c;hpb=585d095517ca2aedab8ad125cc7c39b90e13d5cc diff --git a/server/models/Problem.js b/server/models/Problem.js index 136fb649..5c9af0b1 100644 --- a/server/models/Problem.js +++ b/server/models/Problem.js @@ -11,10 +11,8 @@ const db = require("../utils/database"); * solution: text */ -const ProblemModel = -{ - checkProblem: function(p) - { +const ProblemModel = { + checkProblem: function(p) { return ( p.id.toString().match(/^[0-9]+$/) && p.vid.toString().match(/^[0-9]+$/) && @@ -22,8 +20,7 @@ const ProblemModel = ); }, - create: function(p, cb) - { + create: function(p, cb) { db.serialize(function() { const query = "INSERT INTO Problems " + @@ -31,13 +28,12 @@ const ProblemModel = "VALUES " + "(" + Date.now() + "," + p.uid + "," + p.vid + ",'" + p.fen + "',?,?)"; db.run(query, [p.instruction,p.solution], function(err) { - cb(err, {pid: this.lastID}); + cb(err, { id: this.lastID }); }); }); }, - getAll: function(cb) - { + getAll: function(cb) { db.serialize(function() { const query = "SELECT * " + @@ -48,8 +44,7 @@ const ProblemModel = }); }, - getOne: function(id, cb) - { + getOne: function(id, cb) { db.serialize(function() { const query = "SELECT * " + @@ -61,8 +56,7 @@ const ProblemModel = }); }, - safeUpdate: function(prob, uid) - { + safeUpdate: function(prob, uid) { db.serialize(function() { const query = "UPDATE Problems " + @@ -76,8 +70,7 @@ const ProblemModel = }); }, - safeRemove: function(id, uid) - { + safeRemove: function(id, uid) { db.serialize(function() { const query = "DELETE FROM Problems " +