X-Git-Url: https://git.auder.net/?p=vchess.git;a=blobdiff_plain;f=server%2Fmodels%2FProblem.js;h=bcbefc5f251300c0d2ea64a2be658f62434d97fe;hp=5c9af0b1803d6ff675d4970804bbfd5f74a4d48a;hb=68e19a449db7a12e0a168e99cd750d985c983ba1;hpb=11589e7c4bb1b69473588d133db8b6d1d37b8fee diff --git a/server/models/Problem.js b/server/models/Problem.js index 5c9af0b1..bcbefc5f 100644 --- a/server/models/Problem.js +++ b/server/models/Problem.js @@ -33,12 +33,15 @@ const ProblemModel = { }); }, - getAll: function(cb) { + getNext: function(cursor, cb) { db.serialize(function() { const query = "SELECT * " + - "FROM Problems"; - db.all(query, (err,problems) => { + "FROM Problems " + + "WHERE added < " + cursor + " " + + "ORDER BY added DESC " + + "LIMIT 20"; //TODO: 20 is arbitrary + db.all(query, (err, problems) => { cb(err, problems); }); }); @@ -50,7 +53,7 @@ const ProblemModel = { "SELECT * " + "FROM Problems " + "WHERE id = " + id; - db.get(query, (err,problem) => { + db.get(query, (err, problem) => { cb(err, problem); }); }); @@ -66,7 +69,7 @@ const ProblemModel = { "instruction = ?," + "solution = ? " + "WHERE id = " + prob.id + " AND uid = " + uid; - db.run(query, [prob.instruction,prob.solution]); + db.run(query, [prob.instruction, prob.solution]); }); },