* 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]+$/) &&
);
},
- create: function(p, cb)
- {
+ create: function(p, cb) {
db.serialize(function() {
const query =
"INSERT INTO Problems " +
"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 * " +
});
},
- getOne: function(id, cb)
- {
+ getOne: function(id, cb) {
db.serialize(function() {
const query =
"SELECT * " +
});
},
- safeUpdate: function(prob, uid)
- {
+ safeUpdate: function(prob, uid) {
db.serialize(function() {
const query =
"UPDATE Problems " +
});
},
- safeRemove: function(id, uid)
- {
+ safeRemove: function(id, uid) {
db.serialize(function() {
const query =
"DELETE FROM Problems " +